Searching...

If-else-If

15:52

#include <iostream>
using namespace std;
int main ()
{
    int a = 100;

   // checking boolean condition
   if( a == 10 )
   {
       // if condition is true then print the following
       cout << "Value of a is 10" << endl;
   }
   else if( a == 20 )
   {
       // if else if condition is true
       cout << "Value of a is 20" << endl;
   }
   else if( a == 30 )
   {
       // if else if condition is true
       cout << "Value of a is 30" << endl;
   }
   else
   {
       // if none of the conditions is true
       cout << "Value of a is not matching" << endl;
   }
   cout << "Exact value of a is : " << a << endl;

   return 0;
}

0 comments:

Post a Comment

Thanks For Your FeedBack....