Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
Answer Posted / belsia
#include<stdio.h>
#include<conio.h>
void main()
{
int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter 12 numbers\n");
for(i=0;i<12;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<12;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The even numbers are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}
| Is This Answer Correct ? | 66 Yes | 21 No |
Post New Answer View All Answers
code for quick sort?
What is the use of bitwise operator?
What are the disadvantages of c language?
what does static variable mean?
Is c compiled or interpreted?
What is || operator and how does it function in a program?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
What is advantage of pointer in c?
Can include files be nested? How many levels deep can include files be nested?
why we wont use '&' sing in aceesing the string using scanf
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
What are the benefits of organizational structure?
Why do we need a structure?
Explain what header files do I need in order to define the standard library functions I use?