C Program to Check Whether a given Number is Even or Odd
Write a C program to check whether a given number is even or odd.
C program to check even or odd
/* Aim: To Find whether the number is even or odd */
#include<stdio.h>
int main()
{
int a;
printf("\n Enter Your number:");
scanf("%d",&a);
if (a%2==0)
printf("\n %d is even number \n \n",a);
else
printf("\n %d is odd number \n \n",a);
return 0;
}
Output:
Enter Your number:2 2 is even number
C program to check a number is even or odd using function
/* Aim: Write a function for the function prototype void isEven()*/
#include<stdio.h>
void isEven(); // isEven Function Prototype
void main()
{
isEven();
}
// isEven Function
void isEven()
{
int n;
printf("\n Enter any value:- ");
scanf("%d",&n);
if(n%2==0)
printf("\n %d is even number \n \n",n);
else
printf("\n %d is odd number \n \n",n);
}
Output
Enter any value:- 2 2 is even number
Comments