Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
Answer Posted / dally
#include<stdio.h>
int main()
{
int n,i,j=0,k,count1=0,count2=0;
int a[10],b[10],c[10] ;
printf("Enter value for n\n");
printf("Enter value for array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i] % 2== 0){
count1++;
b[j] = a[i];
j++;
}
else
{
count2++;
c[j] = a[i];
j++;
}
}//End of forloop
j=0;
while(b[j] != '\0')
printf("Even nubers %d\n",b[j]);
printf("No of Even numbers\n");
k =0 ;
while(c[k] != '\0')
printf("Odd nuber %d\n",c[k]);
printf("No of Odd numbers\n");
}
| Is This Answer Correct ? | 6 Yes | 12 No |
Post New Answer View All Answers
How do we open a binary file in Read/Write mode in C?
What is null pointer in c?
What are global variables and explain how do you declare them?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
What is the difference between the expression “++a” and “a++”?
What is a keyword?
What does 2n 4c mean?
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
What does 3 mean in texting?
Explain the concept and use of type void.
For what purpose null pointer used?
What are loops c?
What is #include stdio h?
Describe the header file and its usage in c programming?
Is there a way to jump out of a function or functions?