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
What is oops c?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
What is c standard library?
How does pointer work in c?
how to find anagram without using string functions using only loops in c programming
write a program to generate address labels using structures?
Is main is user defined function?
Explain how do you search data in a data file using random access method?
Explain the properties of union.
What are the 5 types of inheritance in c ++?
What is a wrapper function in c?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
What is the process of writing the null pointer?
What are the different types of pointers used in c language?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?