20_10

Write a C program to replace EVEN and ODD elements by 0 and 1 in an array.

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:
C program to replace EVEN and ODD elements by 0 and 1 in an array


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...