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


Please Help Members By Posting Answers For Below Questions

How can a program be made to print the name of a source file where an error occurs?

735


Explain why c is faster than c++?

579


How can I find out if there are characters available for reading?

649


What is pointers in c with example?

586


How do you use a pointer to a function?

638






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.

3343


How is = symbol different from == symbol in c programming?

618


What is extern c used for?

571


How many levels of indirection in pointers can you have in a single declaration?

598


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1766


What is the use of void pointer and null pointer in c language?

633


Where static variables are stored in memory in c?

527


What is cohesion and coupling in c?

596


What is a pointer in c?

685


What is the difference between memcpy and memmove?

608