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
What are valid signatures for the Main function?
What is the benefit of using const for declaring constants?
write a program for the normal snake games find in most of the mobiles.
What is sizeof in c?
Why double pointer is used in c?
What are qualifiers in c?
What are the types of operators in c?
Why c is called a middle level language?
What is c programming structure?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
What are the features of c languages?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
what are # pragma staments?
Why & is used in scanf in c?
Write a program to find factorial of a number using recursive function.