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
Write a code of a general series where the next element is the sum of last k terms.
What is a nested formula?
How can I manipulate individual bits?
Which is best linux os?
Suggesting that there can be 62 seconds in a minute?
Where define directive used?
What is an array? What the different types of arrays in c?
What is the benefit of using an enum rather than a #define constant?
What is wrong with this program statement?
What is typeof in c?
When would you use a pointer to a function?
What is union and structure?
What is variable and explain rules to declare variable in c?
Explain is it valid to address one element beyond the end of an array?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above