Thursday, August 12, 2021

Switch Statement in C++

 A simple program to demonstrate how to declare and use switch statement using C++ programming language.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.






Program Listing

// switch.cpp

// Jake Rodriguez Pomperada, MAED-IT, MIT

// www.jakerpomperada.blogspot.com and www.jakerpomperada.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines.


#include <iostream>


int main()

{

int a=0;

std::cout <<"\n\n";

std::cout << "\tSwitch Statement in C++";

std::cout <<"\n\n";

std::cout <<"\tGive a Number : ";

std::cin >> a;

std::cout <<"\n";

switch(a) {

case  1 : std::cout <<"\tOne Number";

    break;

case 2 : std::cout <<"\tTwo Number";

    break;

case 3 : std::cout <<"\tThree Number";

    break;

case 4 : std::cout <<"\tFour Number";

    break;

case 5 : std::cout <<"\tFifth Number";

    break;

default : std::cout <<"\tInvalid Number. Try Again.";

      

}

  std::cout <<"\n\n\n";

  std::cout <<"\tEnd of Program";

  std::cout <<"\n";

}


No comments:

Post a Comment