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
How can a program be made to print the name of a source file where an error occurs?
Explain why c is faster than c++?
How can I find out if there are characters available for reading?
What is pointers in c with example?
How do you use a pointer to a function?
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
How is = symbol different from == symbol in c programming?
What is extern c used for?
How many levels of indirection in pointers can you have in a single declaration?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is the use of void pointer and null pointer in c language?
Where static variables are stored in memory in c?
What is cohesion and coupling in c?
What is a pointer in c?
What is the difference between memcpy and memmove?