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


Please Help Members By Posting Answers For Below Questions

how many errors in c explain deply

1633


What is assignment operator?

630


What is the difference between the expression “++a” and “a++”?

652


What does void main return?

610


What's the right way to use errno?

628






how to print the character with maximum occurence and print that number of occurence too in a string given ?

2039


Why cant I open a file by its explicit path?

595


WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

1601


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

2273


what is event driven software and what is procedural driven software?

2019


What is the best style for code layout in c?

634


All technical questions

1514


How do c compilers work?

613


What is the use of getchar() function?

634


Is printf a keyword?

762