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
How pointers are declared?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
State the difference between realloc and free.
Explain bit masking in c?
When should the volatile modifier be used?
Describe how arrays can be passed to a user defined function
What do you understand by friend-functions? How are they used?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
how to introdu5ce my self in serco
Explain how many levels deep can include files be nested?
Is there anything like an ifdef for typedefs?
What is the data segment that is followed by c?
What is wrong with this program statement?
What is binary tree in c?
How to write a multi-statement macro?