Source code:
/*Replace EVEN and ODD elements by 0 and 1 in an array by filling up required code in editable section*/
#include <stdio.h>
int main()
{
int arr[10];
int i=0;
/*Read array elements*/
for (i=0; i<10; i++)
{
printf("Enter the value for %d: ",i);
scanf("%d",&arr[i]);
}
for(i=0;i<10;i++)
{
arr[i]=arr[i]%2;
}
for (i=0; i < 10; i++)
{
printf ("%d\n",arr[i]);
}
return 0;
}
Output:
No comments:
Post a Comment