Lecture# 22 Switch switch explained with example | C++ Programming Tutorials in Urdu

Switch switch

  • It is another decision making statement
  • We use switch statement when we have many choices
  • In case of comparison it is not used

Write a program that inputs a character and finds it is constant or vowel

include"iostream"
using namespace std;
main()
{
char ch;
cout<<"Enter a character = "; cin>>ch;
switch(ch)
{
case 'a':
case 'A':
cout<<"It is a Vowel";
break;
case 'e':
case 'E':
cout<<"It is a Vowel";
break;
case 'i':
case 'I':
cout<<"It is a Vowel";
break;
case 'o':
case 'O':
cout<<"It is a Vowel";
break;
case 'u':
case 'U':
cout<<"It is a Vowel";
break;
default:
cout<<"It is a constant";
}
}

Watch video for more information

Leave a Reply