Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
Answer Posted / prakash.
/* program to print even nums in even position,odd in odd
position*/
/* Ex: 2 1 3 4 output:2 1 4 3*/
/* work for almost all check it if any wrong*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[4],j=0,i;
int b[4],e=0,od=1;
clrscr();
for(i=0;i<4;i++)
{
printf("Enter A number : ");
scanf("%d",&a[i]);
}
for(i=0;i<4;i++)
{
if((a[i]%2)==0)
{
j=e;
b[j]=a[i];
e=j+2;
}
else
{
j=od;
b[j]=a[i];
od=od+2;
}
}
for(j=0;j<4;j++)
{
printf("%d\n",b[j]);
}
getch();
return;
}
| Is This Answer Correct ? | 4 Yes | 11 No |
Post New Answer View All Answers
What is adt in c programming?
how logic is used
What are structure types in C?
What are categories used for in c?
Here is a good puzzle: how do you write a program which produces its own source code as output?
What is void c?
Give me the code of in-order recursive and non-recursive.
What is the best organizational structure?
Can you tell me how to check whether a linked list is circular?
What does the file stdio.h contain?
"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
how many errors in c explain deply
Difference between pass by reference and pass by value?
When should the const modifier be used?
What is wrong in this statement?