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
Explain what are binary trees?
What is a MAC Address?
Differentiate between static and dynamic modeling.
Why is it that not all header files are declared in every C program?
What is c system32 taskhostw exe?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
Do pointers take up memory?
What is a macro in c preprocessor?
Explain high-order bytes.
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Can a file other than a .h file be included with #include?
Compare and contrast compilers from interpreters.
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
how to build a exercise findig min number of e heap with list imlemented?
How many bytes are occupied by near, far and huge pointers (dos)?