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 IMPLEMENTATION OF POINTERS
#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();
}
thank you
| Is This Answer Correct ? | 3 Yes | 15 No |
Post New Answer View All Answers
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
Where are c variables stored in memory?
Define and explain about ! Operator?
What Is The Difference Between Null And Void Pointer?
What is the use of bit field?
What are qualifiers in c?
What would be an example of a structure analogous to structure c?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
What is scope of variable in c?
What is unary operator?
What is calloc() function?
Which built-in library function can be used to match a patter from the string?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
How can I invoke another program or command and trap its output?
What are volatile variables in c?