How to display oddnumbers from a list of numbers(0-100) using two combo boxes and a button i.e( if we have two combo boxes placed on the form one containing numbers and then how to display even or odd numbers from a list of these numbers)
chandra sekhar
Here is an interesting solution //Because all even numbers are divisible by two, we can use the modulo division operator to see if there is any remainder when the //number is divided by two. If there is no remainder (it returns zero) then the number is definitely even. Zero is an even number; this //method is correct for zero. private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 100; i++) { if (IsEven(i)) { combobox1.Items.Add(i); } if (IsOdd(i)) { combobox2.Items.Add(i); } } } private bool IsOdd(int value) { return value%2 == 1; } private bool IsEven(int value) { return value%2 == 0; }
Hi Chandra sekhar,
Please try to be more specific. The question is not clear....
Hopefully answered in the forums. See http://www.c-sharpcorner.com/Forums/Thread/131862/how-to-display-oddnumbers-from-a-list-of-numbers0-100.aspx
i dont know about this one