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
When we use void main and int main?
hi send me sample aptitude papers of cts?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
What is the use of typedef in c?
How pointer is different from array?
What is header file definition?
What is a macro in c preprocessor?
What are the main characteristics of c language describe the structure of ac program?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
How does pointer work in c?
How do you construct an increment statement or decrement statement in C?
How many types of functions are there in c?
What are # preprocessor operator in c?
What are dangling pointers in c?