If..else Ladder Example Program In C++


Definition

In C++, The if..else ladder statement is used to set of code blocks in sequence. If the condition is inquired only when all above if conditions are false. If any of the conditional is evaluates to true, then it will execute the corresponding code block and it doesn't execute other code blocks exits entire if-else ladder.

If..else Ladder Syntax

if (condition_1) {
   // Block For Condition Success
} else if (condition_2) {
   // Block For Condition Success
} else if (condition_3) {
   // Block For Condition Success
} else {
   // Block For Condition Fail
}

Simple If..Else Ladder Example Program for find vowels In C++

/* Simple If..Else Ladder Example Program In C++ */
/* If..Else Ladder Programs, Find Vowels,Control Programs,C++ Examples */

// Header Files
#include<iostream>
#include<conio.h>

//Main Function

using namespace std;

int main() {
   // Local Variable 'ch' Declaration
   char ch;

   cout << "Simple If..Else Ladder Statement Example Program\n";

   cout << "Enter the Letter (In Capital Letter): ";
   cin >> ch;

   // If..Else Ladder Check
   if (ch == 'A') {
      cout << "Your Character Is A.Your Character is Vowel\n";
   } else if (ch == 'E') {
      cout << "Your Character Is E.Your Character is Vowel\n";
   } else if (ch == 'I') {
      cout << "Your Character Is I.Your Character is Vowel\n";
   } else if (ch == 'O') {
      cout << "Your Character Is O.Your Character is Vowel\n";
   } else if (ch == 'U') {
      cout << "Your Character Is U.Your Character is Vowel\n";
   } else {
      cout << "Your Character is Not Vowel.Otherwise Not a Capital Letter\n";
   }

   // Wait For Output Screen
   getch();

   //Main Function return Statement
   return 0;
}

Sample Output

Simple If..Else Ladder Statement Example Program
Enter the Letter (In Capital Letter): I
Your Character Is I.Your Character is Vowel


Simple If..Else Ladder Statement Example Program
Enter the Letter (In Capital Letter): X
Your Character is Not Vowel.Otherwise Not a Capital Letter