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 is cohesion in c?
how to find anagram without using string functions using only loops in c programming
What does sizeof function do?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
What are the two forms of #include directive?
how can f be used for both float and double arguments in printf? Are not they different types?
Why do we need arrays in c?
What is dangling pointer in c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Why is structure important for a child?
What is hungarian notation? Is it worthwhile?
Differentiate between new and malloc(), delete and free() ?
What is far pointer in c?
What is the difference between int main and void main in c?
what is bit rate & baud rate? plz give wave forms