Even or odd Program in C
C program to check Even or Odd Numbers using different methods. we use the reminder theorem to check the given the number is Even or odd.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the number\n");
scanf("%d",&n);
if(n%2==0)
{
printf("%d is Even number",n);
}
else
{
printf("%d is Odd number");
}
getch();
}
Output:-
Even or odd number program using conditional operator
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the number\n");
scanf("%d",&n);
n%2==0?printf("Even"):printf("Odd");
getch();
}
Output:-
No comments:
Post a Comment