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
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
What is the role of && operator in a program code?
How can I direct output to the printer?
What is the size of enum in c?
What is a program?
What are the Advantages of using macro
How many levels deep can include files be nested?
Do you know the use of 'auto' keyword?
What does double pointer mean in c?
Using which language Test cases are added in .ptu file of RTRT unit testing???
all c language question
Give the rules for variable declaration?
What is a function simple definition?
What is scope rule in c?
What is calloc in c?