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
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
How can you avoid including a header more than once?
Explain the difference between #include "..." And #include <...> In c?
How many levels of indirection in pointers can you have in a single declaration?
What is ponter?
Define VARIABLE?
What is d'n in c?
Explain what does the function toupper() do?
What is difference between structure and union in c?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
what value is returned to operating system after program execution?
What are pointers in C? Give an example where to illustrate their significance.
In which header file is the null macro defined?
Do array subscripts always start with zero?
Why double pointer is used in c?