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
Why c is called a middle level language?
What is scanf () in c?
What is linear search?
What is variable declaration and definition in c?
Explain how do you convert strings to numbers in c?
What does p mean in physics?
What is dynamic dispatch in c++?
what are # pragma staments?
What is s or c?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
Explain how do you view the path?
What is memory leak in c?
Explain what is the difference between a string and an array?
How can you pass an array to a function by value?