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 difference between null and nul in c language

2 Answers  


write a c programs to do multiplication of two numbers with out using arithmatic operator ??????????

7 Answers   Infosys, TCS,


please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }

3 Answers  


How do you determine if a string is a palindrome?

1 Answers  


Why isnt there a numbered, multi-level break statement to break out

0 Answers  


How can I automatically locate a programs configuration files in the same directory as the executable?

0 Answers  


What do you mean by a sequential access file?

0 Answers  


What is the difference between typeof(foo) and myFoo.GetType()?

2 Answers   Synergy,


What is local and global variable in c?

0 Answers  


What is return type in c?

0 Answers  


count the numbers between 100 and 300, that star with 2 and ends with 2

5 Answers   Mind Tree,


what is difference between c and c++

4 Answers  


Categories