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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Why isn't any of this standardized in c? Any real program has to do some of these things.

615


How do we make a global variable accessible across files? Explain the extern keyword?

1412


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1244


What is zero based addressing?

699


What is a #include preprocessor?

603






What are enums in c?

649


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

646


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3170


What are the 4 data types?

586


What is the difference between %d and %i?

584


Explain what is meant by high-order and low-order bytes?

626


What are the types of c language?

543


Explain pointer. What are function pointers in C?

617


What is the difference between scanf and fscanf?

652


Does c have enums?

590