0
Seperate Even and odd elements of an array using pointers in C program
Please help me out with this, i am newbie here ,i have to complete it today
5 ответов
+ 1
Instead of making an array to put the integers, you should create a pointer to an integer array. Then just do the same thing, check each number and output if even or odd when needed
+ 1
Provide your attempt. I'll need that today.
+ 1
How to do it using pointers
+ 1
This question has a familar ring. See the challenge below:
https://www.sololearn.com/post/1269153/?ref=app
0
#include <stdio.h>
int main()
{
int a[10],i,n,*p;
printf ("enter the number of elements:\n");
scanf("%d",&n);
printf ("enter elements: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("------------------------\n");
printf ("even numbers are: \n");
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
printf ("%d\n",a[i]);
}
}
printf("-------------------------\n");
printf ("odd numbers are: \n");
for(i=0;i<n;i++)
{
if(a[i]%2!=0)
{
printf ("%d\n",a[i]);
}
}
return 0;
}