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


Please Help Members By Posting Answers For Below Questions

Difference between goto, long jmp() and setjmp()?

958


How to declare pointer variables?

914


What are the different types of C instructions?

997


What does the function toupper() do?

886


What is void c?

783


Hi can anyone tell what is a start up code?

1838


Can we compile a program without main() function?

885


What does sizeof function do?

885


How can you be sure that a program follows the ANSI C standard?

1384


How a string is stored in c?

818


What are the two types of structure?

830


How do you use a 'Local Block'?

941


What are the types of variables in c?

783


What are the Advantages of using macro

910


When should structures be passed by values or by references?

827