Computer Science, asked by mukesh4794, 1 month ago

WAP to input 5 elements in an array and print the sum of even and odd only them

Answers

Answered by shahzadiasra123
0

Explanation:

/*Print odd and even numbers of an array separately*/

#include<stdio.h>

#define MAX 50

void main()

{

int arr[MAX],n,i;

printf("Enter size of Array: ");

scanf("%d",&n);

printf("\n Enter %d positive elements\n",n);

for(i=0;i<n;i++)

{

scanf("%d",&arr[i]);

}

printf("\n\nEven numbers: \n");

for(i=0;i<n;i++)

{

if(arr[i]%2==0)

{

printf("%d ",arr[i]);

}

}

printf("\nOdd numbers: ");

for(i=0;i<n;i++)

{

if(arr[i]%2!=0)

{

printf("%d",arr[i]);

}

}

}

Similar questions