C-Programming
Write a program in c to check given number is even or not ?
Home/Write a program in c to check given number is even or not ?
Write a program in c to check given number is even or not ?
in c-programming
Write a program in c to check given number is even or not
Steps of programming:-
01.Initialize a variable(e.g n;)
02.Again use printf() and scanf() function;
03.Now use %d for integer value;
04.Start a loop for (if,else;)
05.And again use the formula(n%2==0)
06.In this loop first we use if statement for print a even number
07.In this loop second we use if statement for print a not even number/odd number
Code:-
#include <stdio.h>
#include<conio.h>
void main()
{
int n;
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\n enter the number you want");
scanf("%d", &n);
if (n%2 == 0)
printf("\n given number is even");
else
printf("\n given number is not even");
printf("\n enter the number you want");
scanf("%d", &n);
if (n%2 == 0)
printf("\n given number is even");
else
printf("\n given number is not even");
getch();
}
}
DizIT_Operators
Thank-You
Thank-You
No comments:
Post a Comment