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
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
Explain high-order and low-order bytes.
explain what is a newline escape sequence?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What are c preprocessors?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
What is FIFO?
Explain how are 16- and 32-bit numbers stored?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
What does sizeof function do?
define string ?
What is array of structure in c?
What does main () mean in c?
Why do we use int main instead of void main in c?