Skip to main content

C PROGRAM: Simple explanation of c program to find whether given number is even or odd using if-else statement.

C Programming


What is even number? What is odd number? How to find  whether given number is even or odd using if-else statement? We will be discussing about the c program to find whether given number is even or odd  and the other details.


what is Even number?
  The number which are divided by 2 are all known as Even number.
The last number of even number will always be 0,2,4,6 and 8.
   example:
                24, 56,94... 

What is odd number?
  The number which are not divided by 2 are all known as odd number.
The last number will always be 1,3,5,7 and 9.
    example:
                 23,89,243...

C program to find whether given number is even or odd.

c program to find whether given number is even or odd

Explaination:
  • Header file stdio.h standard input and output to get input and show output, conio.h console input and output.
  • void main -  function returning value will be null.
  • int - declare the type of variable. where n variable represent number.
  • clrscr - clear the screen.
  • printf - used to print the output screen.
  • scanf - used to accept input (%d), and read (&n).
  • getch - used to hold the screen until the user gives any type of input.
  • I have used if statement.
logic behind the program
 
  • if statement has the condition n(number) is divided by 2, the even number must be divisible by 2.
  • If the condition is true, then the first statement that is, "num is even number" is printed.
  • If the condition is false then the second statement that is "num is odd number" is printed.
Output:

here are some output for the above program.

output of  c program to find whether given number is even or odd


The above program is used to find whether given number is even or odd. It is also an example for if-else statement.
check out other example of if-else statement

In following days we will discuss more programs in detail. If you like to learn more just follow me regularly. If you have any question to ask mention below in comment. Thank you......

Comments