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

A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

671


How can you avoid including a header more than once?

568


Explain the difference between #include "..." And #include <...> In c?

635


How many levels of indirection in pointers can you have in a single declaration?

598


What is ponter?

777






Define VARIABLE?

692


What is d'n in c?

638


Explain what does the function toupper() do?

638


What is difference between structure and union in c?

551


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1263


what value is returned to operating system after program execution?

1608


What are pointers in C? Give an example where to illustrate their significance.

754


In which header file is the null macro defined?

861


Do array subscripts always start with zero?

788


Why double pointer is used in c?

573