C++ Program using If-else Statement





This program shows the simple use of if-else statement. In this condition, if one statement goes wrong, other condition is applied.

This is a program to find a leap year.

#include<iostream.h>

#include<conio.h>

Void main ()

{

Int year;

Clrscr ();

Cout<<”\n enter year (in 4- digits)”;

Cin>>year;

If (year % 100==0)

{

If (year % 400 == 0)

Cout<<”\n leap year”;

Else

Cout<<”\n not a leap year”;

}

Else

If (year % 4 ==0)

Cout<<”\n leap year”;

Else

Cout<<”\n not a leap year”;

getch ();

}



Related posts:

  1. C++ Program Using Switch Statement This program is used to check whether the entered character...
  2. Switch Statement In C++ Switch statement in c++ C++ provides a multi way decision...
  3. If Else Statement In C++ If else statement in c++ Its general form is:- If...
  4. If Statements In C++ If statements in c++ It is used to test the...
  5. C++ Program using Stadd() and Stshow() This program is designed in-order to take input  of 5...