How to create a program of even or odd number in C

Let’s write a program to find even or odd number in C

Step 1: Let’s open turbo c/c++ and write the following code in it.

Add preprocessor file

#include<stdio.h>
#include<conio.h>

void main()
{
int n;
clrscr();
print(“enter any number:”);
scanf(“%d”,&n);
if(n%2==0)
{
printf(“number is even”);
}
else
{
printf(“number is odd”);
}
getch();
}

1

Step 2: Save it by pressing (F2) and name it ODDEVEN.CPP and click ok.

2

Step 3: Now, you have to compile .it means to check errors in program for successfully run.Click on Compile or press ALT+F9 then click on OK .

3

Step 4: Run the program .press ALT+R and see the output.

//Output : 

Suppose we enter a no 10 then the result is number is even.

4

Tags: ,