Write a c program to print the even numbers followed by odd
numbers in an array without using additional array
Answer / 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 |
Describe advantages and disadvantages of the various stock sorting algorithms
List the different types of c tokens?
How does selection sort work in c?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What do you mean by a local block?
a 'c' program to tell that the set of three coordinates lie on a same line
Explain what header files do I need in order to define the standard library functions I use?
How can I pad a string to a known length?
What is c language used for?
What is the difference between test design and test case design?
Difference between data structure and data base.
7 Answers CTS, Value Labs, Zoho,
Binary tree traversing