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 c value paradox explain?
What is the mean of function?
What is formal argument?
Explain how does flowchart help in writing a program?
In which language linux is written?
Why is it usually a bad idea to use gets()? Suggest a workaround.
What is unsigned int in c?
What is the maximum length of an identifier?
Difference between goto, long jmp() and setjmp()?
Can you explain the four storage classes in C?
When is a “switch” statement preferable over an “if” statement?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
Explain the priority queues?
How do we print only part of a string in c?
I need previous papers of CSC.......plz help out by posting them.......