English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

Simply loop through the list of numbers and compute:

'number' modulo '2'

In C, that would be:

number % 2

A modulus of 2 would return a '1' for odd numbers, and '0' for even numbers (since even numbers divide by 2 with no remainder, and odd numbers divide by 2 with a remainder of 1).

Example:

int index;
int numArray[25];

...(store the 25 numbers in the array)...

for(index = 0; index < 25; index++) {
if(numArray[i] % 2) {
printf("%d\n", numArray[i]);
}
}

2006-11-03 09:37:24 · answer #1 · answered by cypherkey 2 · 1 0

For cnt = 1 to 25
Input X
if int(X/2) <> X/2 then
Print X
endif
next cnt

2006-11-03 17:33:57 · answer #2 · answered by nondescript 7 · 1 0

int a[25],i;


for(i=1;i<=25;i++)
{
if(a[i]%2 !=0)
{
cout<<"The number "< }
}

2006-11-06 13:20:33 · answer #3 · answered by life goes on... 2 · 0 0

fedest.com, questions and answers