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

20th Nov 2021, 11:09 AM
31_Shreyash Jeughale
31_Shreyash Jeughale - avatar
5 Respuestas
+ 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
20th Nov 2021, 11:52 AM
Slick
Slick - avatar
+ 1
Provide your attempt. I'll need that today.
20th Nov 2021, 11:26 AM
Slick
Slick - avatar
+ 1
How to do it using pointers
20th Nov 2021, 11:50 AM
31_Shreyash Jeughale
31_Shreyash Jeughale - avatar
+ 1
This question has a familar ring. See the challenge below: https://www.sololearn.com/post/1269153/?ref=app
20th Nov 2021, 2:36 PM
Brian
Brian - avatar
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; }
20th Nov 2021, 11:49 AM
31_Shreyash Jeughale
31_Shreyash Jeughale - avatar