Find Odd or Even Program in C
Here, you will get an example code to find odd or even program in c programming. First, we will take a number as input and finds whether that number is even or odd. Here variable n is used to represents the number, which is checked for even or odd.
For checking whether the number is even or odd the value of n is divided by 2 if the result(remainder) is zero then the number is even otherwise number is odd.
Even Number Definition
Even Numbers :- A Number which is completely divided by 2 and generate 0 remainder is know as Even numbers. For example 2,4,6,8,10,12,14,16,18………. are Even numbers.
Odd Number Definition
Odd Number :- A Number which is not completely divided by 2 and generate some reminder other then 0 is called Odd Number. For example 1,3,5,7,9,11,13,15,17,19…..are odd numbers
Algorithm
Step 1: Input any integer number.
Step 2: Check if number is even(divide by 2).
Step 3: If number is even print “Number is Even“.
Step 4: If not print “Number is Odd“.
Data Flow Diagram(DFD)
![DFD of Odd or Even Program in C DFD of Odd or Even Program in C](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiEjNmYnFSI9R66o26BiaQ3yO9X299pcYT98AoLz5KdTeqXtJWB2ABeP0CwtjXlUFA61BxejSs8qDA2wsk31bNW8qdOGKH6udWyQ2worI5OLp3LDH1UItzgs0P0UnD6qdkl8patKwRYX-eSP-ImMjHvByvUKK8d7_6fej5urknn_8TWN5imMtbBDus/s16000/evenodd.png)
Program code to Find Odd or Even Program in C
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<stdio.h> #include<conio.h> void main( ) { int n; printf(“\nInput a number:”); scanf(“%d”,&n); if(n%2==0) printf(“\n%d Number is even”,n); else printf(“\n%d Number is odd”,n); getch( ); } |
Input
Enter a number : 7
Output
7 Number is odd
Check out our other C programming Examples