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
Does c have enums?
What is a pointer in c plus plus?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Explain the concept and use of type void.
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
What are loops in c?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
How to declare pointer variables?
What happens if a header file is included twice?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What are integer variable, floating-point variable and character variable?
What is a structure member in c?
What is meant by recursion?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
Does c have class?