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
Explain what are multidimensional arrays?
What are c identifiers?
Mention four important string handling functions in c languages .
Is file a keyword in c?
Which function in C can be used to append a string to another string?
What are the header files used in c language?
What is volatile variable how do you declare it?
If null and 0 are equivalent as null pointer constants, which should I use?
Who developed c language and when?
Is stack a keyword in c?
What are 3 types of structures?
Is c compiled or interpreted?
Differentiate between null and void pointers.
What is the difference between pure virtual function and virtual function?
How do you initialize pointer variables?