Write a c program to print the even numbers followed by odd
numbers in an array without using additional array



Write a c program to print the even numbers followed by odd numbers in an array without using addi..

Answer / nitin garg

#include <stdio.h>
#include <conio.h>
#include <string.h>


int main()
{
int num[100],n,i,j;
printf("how many elements you enter
");
scanf("%d",&n);
printf("Enter %d elements
",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}

printf("

print the even numbers followed by odd
numbers
");
for(i=0;i<n;i++)
{
if(num[i]%2==0 && num[i+1]%2!=0)
printf("%d
",num[i]);
}
getch();
}


Output:
how many elements you enter
10
Enter 10 elements
2
4
6
8
10
12
14
16
18
19

print the even numbers followed by odd
numbers
18

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

What is the difference between union and structure in c?

0 Answers  


Is c pass by value or reference?

0 Answers  


What is a shell structure examples?

0 Answers  


what is pointer ?

10 Answers   Kernex Micro Systems,


What is your stream meaning?

0 Answers  






a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

0 Answers  


What is the diffrent between while and do while statement ?

6 Answers  


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

0 Answers  


how to calculate the time complexity of a given algorithm? pls give exaples..mainly for the coplexities such as O(log n),O(n log n)...

1 Answers   Infosys,


change to postfix a/(b+c*d-e)

8 Answers   Value Labs,


what does ‘#include’ mean?

1 Answers   TCS,


Why do u use # before include in a C Progam?

9 Answers   IBM,


Categories