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 what is the difference between a free-standing and a hosted environment?
What are 3 types of structures?
Why c is a mother language?
What are linker error?
What is return in c programming?
What extern c means?
What is structure in c language?
What is array of structure in c programming?
How can you return multiple values from a function?
Explain what is wrong with this program statement? Void = 10;
What is the use of header files?
Difference between pass by reference and pass by value?
How do I determine whether a character is numeric, alphabetic, and so on?
What is static memory allocation?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?