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 |
Why is C called a middle-level language?
Explain the properties of union. What is the size of a union variable
WHAT IS C?
if function is declared as static in one source file, if I would like to use the same function in some other source file...is it possible....how ?
What is the size of structure pointer in c?
from which concept of 'c', the static member function of 'c++' has came?
15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to?
write a function that accepts an array A with n elements and array B with n-1 elements. Find the missing one in array B,with an optimized manner?
what is the difference between strcpy() and memcpy() function?
Why doesn't the code "a[i] = i++;" work?
write a program that prints a pascal triangle based on the user input(like how many stages) in an efficient time and optimized code?
Where register variables are stored in c?