//C Program to Print Even and Odd Numbers in an Array
#include "stdio.h"
int main (){
int arr[200],i,n;
printf ("enter the size of arrey :");
scanf ("%i",&n);
printf ("enter all %d elements in the arrey :",n);
for (i=0;i<n;i++){
scanf ("%i",&arr[i]);
}
printf ("all even elements in the arrey are :\n");
for (i=0;i<n;i++){
if (arr[i]%2==0)
printf ("%i\n",arr[i]);
}
printf ("\nall odd elements in the arrey are :\n");
for (i=0;i<n;i++){
if (arr[i]%2!=0)
printf ("%i\n ",arr[i]);
}
return 0;
}
output output output output output
enter the size of arrey :6
enter all 6 elements in the arrey :34
54
56
78
77
23
all even elements in the arrey are :
34
54
56
78
all odd elements in the arrey are :
77
23
No comments:
Post a Comment