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
how many errors in c explain deply
What is assignment operator?
What is the difference between the expression “++a” and “a++”?
What does void main return?
What's the right way to use errno?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Why cant I open a file by its explicit path?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
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.
what is event driven software and what is procedural driven software?
What is the best style for code layout in c?
All technical questions
How do c compilers work?
What is the use of getchar() function?
Is printf a keyword?