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

Is a house a shell structure?

699


how do you programme Carrier Sense Multiple Access

1522


What is meant by keywords in c?

620


the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b

1908


What is the purpose of main( ) in c language?

628






in iso what are the common technological language?

1639


What are header files and explain what are its uses in c programming?

616


What are external variables in c?

549


How to write c functions that modify head pointer of a linked list?

548


Explain how can you restore a redirected standard stream?

594


What are control structures? What are the different types?

602


What is meant by inheritance?

636


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

761


What is a char c?

596


Why doesnt this code work?

620