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
What is a function simple definition?
What is the difference between new and malloc functions?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
What is the best way to comment out a section of code that contains comments?
What is the difference between a free-standing and a hosted environment?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is wrong in this statement?
What is pointer to pointer in c language?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
Why should I prototype a function?
Are there any problems with performing mathematical operations on different variable types?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
Do you know what are bitwise shift operators in c programming?
What is malloc return c?