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 isn't any of this standardized in c? Any real program has to do some of these things.
How do we make a global variable accessible across files? Explain the extern keyword?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What is zero based addressing?
What is a #include preprocessor?
What are enums in c?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What are the 4 data types?
What is the difference between %d and %i?
Explain what is meant by high-order and low-order bytes?
What are the types of c language?
Explain pointer. What are function pointers in C?
What is the difference between scanf and fscanf?
Does c have enums?