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

How reliable are floating-point comparisons?

872


What is s in c?

855


Explain how can you check to see whether a symbol is defined?

911


Explain what is the difference between null and nul?

924


What is oops c?

888


write a program in c language to print your bio-data on the screen by using functions.

6576


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

1942


what is the significance of static storage class specifier?

1956


write a program to concatenation the string using switch case?

1844


how can f be used for both float and double arguments in printf? Are not they different types?

865


Explain what are multibyte characters?

896


What is the purpose of void pointer?

833


How can I sort a linked list?

834


What is 1f in c?

2340


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

901