Replace all even elements by 0 and odd by 1 in an array

C program to replace all even elements by 0 and odd by 1 in one dimensional array.

Program

#include<stdio.h>
#include<conio.h>
#define MAX 50

void main()
{
	int arr[MAX];
    int i, n;

    printf("Enter the number of elements in the array\t:");
    scanf("%d",&n);
    printf("Enter the elements\n");
    for(i=0;i<n;i++)
    {
        printf("Element %d\t:",i+1);
        scanf("%d",&arr[i]);
    }

    for(i=0;i<n;i++)
    {
        if(arr[i]%2==0)
            arr[i] = 0;
        else
            arr[i] = 1;
    }

    printf("\nElements of the array are\n");
    for(i=0;i<n;i++)
    {
        printf("Element %d\t:%d\n",i+1,arr[i]);
    }
    getch();
}

Output

Enter the number of elements in the array       :8
Enter the elements
Element 1       :74
Element 2       :41
Element 3       :85
Element 4       :52
Element 5       :96
Element 6       :63
Element 7       :54
Element 8       :56

Elements of the array are
Element 1       :0
Element 2       :1
Element 3       :1
Element 4       :0
Element 5       :0
Element 6       :1
Element 7       :0
Element 8       :0