Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
Answer Posted / vignesh1988i
A SMALL FLOWER BRACES IS LEFT.......
THE FOLLOWING IS THE RIGHT PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],*ptr[50],count=0,n,flag=1;
printf("enter the max. elements to be entered :");
scanf("%d",&n);
int k=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2!=0)
{
ptr[k]=&a[i];
count++;
k++;
}
else
flag=0;
}
printf("odd numbers :\n");
for(i=0;i<count;i++)
printf("%d\n",*(*(ptr+i)));
if(flag==0)
{
printf("even numbers :\n");
for(i=0;i<n;i++)
{
if(ptr[i]!=&a[i])
printf("%d\n",a[i]);
}
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 12 No |
Post New Answer View All Answers
Explain can static variables be declared in a header file?
Is a house a shell structure?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
What is the general form of a C program?
What are reserved words with a programming language?
What is the general form of function in c?
What is pre-emptive data structure and explain it with example?
Why we use stdio h in c?
What is the size of enum in c?
What is an operator?
What is oops c?
code for find determinent of amatrix
What is wrong in this statement? scanf(ā%dā,whatnumber);
Explain what is the heap?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?