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
What is hungarian notation? Is it worthwhile?
How is a structure member accessed?
How is actual parameter different from the formal parameter?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Explain the difference between getch() and getche() in c?
List some of the static data structures in C?
Why header files are used?
Explain how can I prevent another program from modifying part of a file that I am modifying?
Explain the term printf() and scanf() used in c language?
Explain built-in function?
All technical questions
Explain how do you convert strings to numbers in c?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
What is the difference between far and near ?
State the difference between x3 and x[3].