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


Please Help Members By Posting Answers For Below Questions

Write a code of a general series where the next element is the sum of last k terms.

596


What is a nested formula?

605


How can I manipulate individual bits?

608


Which is best linux os?

565


Suggesting that there can be 62 seconds in a minute?

598






Where define directive used?

607


What is an array? What the different types of arrays in c?

660


What is the benefit of using an enum rather than a #define constant?

661


What is wrong with this program statement?

610


What is typeof in c?

609


When would you use a pointer to a function?

589


What is union and structure?

574


What is variable and explain rules to declare variable in c?

555


Explain is it valid to address one element beyond the end of an array?

736


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

736