w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Monday, January 6, 2020

C Program to check Odd & Even Numbers in an Array


Simple approach: A number is said to be Even if it is completely divisible by 2. A number is said to be Odd if it is leaves 1 as remainder on dividing by 2.

#include <stdio.h>

#include<conio.h>void main(){ int array[100], i, num;

clrscr();

printf("Enter the size of an array \n");

 scanf("%d", &num);

printf("Enter the elements of the array \n"); 

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

{

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

}

 printf("Even numbers in the array are - ");

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

 {

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

{

printf("%d \t", array[i]);

}

} 

printf("\n Odd numbers in the array are -");

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

{

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

{

printf("%d \t", array[i]);

}

} 

getch();

}

No comments:

Post a Comment

for more information please share like comment and subscribe