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 the purpose of main( ) in c language?
Is c a great language, or what?
How will you write a code for accessing the length of an array without assigning it to another variable?
hi, which software companys will take,if d candidate's % is jst 55%?
Is printf a keyword?
which is an algorithm for sorting in a growing Lexicographic order
What should malloc(0) do?
Why we use break in c?
Explain b+ tree?
What are the advantages of using Unions?
explain what are pointers?
What is the explanation for the dangling pointer in c?
What is bss in c?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.