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
Differentiate between Macro and ordinary definition.
What are predefined functions in c?
What are the application of c?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What does %p mean?
Explain how can you be sure that a program follows the ansi c standard?
Explain what are multibyte characters?
Why is struct padding needed?
What is c language used for?
Is main a keyword in c?
What are the functions to open and close the file in c language?
Why pointers are used?
In c language can we compile a program without main() function?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
What is unary operator?