SlideShare a Scribd company logo
1 of 13
Switch example 1
                                          http://eglobiotraining.com.
#include <iostream>
using namespace std;
int main(void)
{
  char grade;
  cout << "Enter your grade: ";
  cin >> grade;
  switch (grade)
  {
  case 'a':case 'A':
    cout << "Your average must be between 90 - 100"
       << endl;
    break;
  case 'b':
  case 'B':
    cout << "Your average must be between 80 - 89"
       << endl;
    break;
  case 'c':
  case 'C':
    cout << "Your average must be between 70 - 79"
       << endl;
    break;
  case 'd':
  case 'D':
    cout << "Your average must be between 60 - 69"
       << endl;
    break;
  default:
    cout << "Your average must be below 60" << endl;
  }
return 0;
}
Screenshot
                  http://eglobiotraining.com




Enter your grade: 1
Your average must be below 60
Switch example 2
•   #include <iostream>                                                     http://eglobiotraining.com
•   using namespace std;
•   int main()
•   {
•                 int choice;

•                 cout << "MENUnn";

•                 cout << "1." << "t" << "Lobstern";
•                 cout << "2." << "t" << "Steakn";
•                 cout << "3." << "t" << "Turkeyn";
•                 cout << "4." << "t" << "Hambergern";
•                 cout << "5." << "t" << "Vegetariannn";

•                 cout << "Choose your dinner entree: ";
•                 cin >> choice;

•                 cout << endl;

•                 switch (choice)
•                 {
•                 case 1: cout << "Lobster is my favorite! Dig in!nn";
•                                       break;

•                 case 2: cout << "Yummy! Steak is great...n"
•                                         << "but limit yourself to once a week," << endl
•                                         << "or risk the chance of high cholesterol!nn";
•                                      break;

•                 case 3: cout << "Turkey is healthier than steak! ...Enjoy!nn";
•                                       break;

•                 case 4: cout << "Hamburger is another form of steak. :-)nn";
•                                      break;

•                 case 5: cout << "Finally, a vegitarian is in the house!nn";
•                                        break;

•                 default: cout << "Invalid number, please enter a number"
•                                            << " from the entrees above.nn";
•                                        break;
•                 }
•                 return 0;
•   }
Screenshot
                 http://eglobiotraining.com




MENU 1. Lobster 2. Steak 3. Turkey 4.
 Hamberger 5. Vegetarian Choose your dinner
 entree: 2 Yummy! Steak is great... but limit
 yourself to once a week, or risk the chance of
 high cholesterol!
Switch example 3
                                                               http://eglobiotraining.com


#include <iostream>
using namespace std;
int main()
{
       char letter;

      cout << "A)tHouse MDn"
        << "B)tAmerican Idlen"
        << "C)tFamily Guynn";

      cout << "What TV show do you like (Enter A, B, C)?: ";

      cin >> letter;

      cout << endl;

      switch (toupper(letter))
      {
      case 'A' : cout << "Dr. House is a radical doctor!nn";
                   break;
      case 'B' : cout << "Wannabe singers!nn";
                   break;
      case 'C' : cout << "One of the craziest cartoons Ive ever seen.nn";
                   break;
      default: cout << "Invalid choice.nn";
                   break;
      }
      return 0;
}
Screenshot
                      http://eglobiotraining.com

/
    *============================[output]========
    ========================= A) House MD B)
    American Idle C) Family Guy What TV show do you like
    (Enter A, B, C)?: a Dr. House is a radical doctor! Press
    any key to continue . . .
    =============================[output
    2]================================ A) House
    MD B) American Idle C) Family Guy What TV show do
    you like (Enter A, B, C)?: z Invalid choice. Press any key
    to continue . . .
    ============================================
    ==========================*/
Switch example 4
                                                                       http://eglobiotraining.com
#include <iostream>
using namespace std;
int main()
{
        int num;

       cout << "MENUnn";
       cout << "1." << "t" << "Lobstern";
       cout << "2." << "t" << "Steakn";
       cout << "3." << "t" << "Turkeyn";
       cout << "4." << "t" << "Hambergern";
       cout << "5." << "t" << "Vegetariannn";
       cout << "Choose your dinner entree: ";
       cin >> num;

       cout << endl;

       if (num == 1)
                       {
                           cout << "Lobster is my favorite! Dig in!nn";
                       }

                       else if (num == 2)
                       {
                         cout << "Yummy! Steak is great...n"
                            << "but limit yourself to once a week,n"
                            << "or risk the chance of high cholesterol!nn";
                       }

                       else if (num == 3)
                       {
                         cout << "Turkey is healthier than steak! ...Enjoy!nn";
                       }

                       else if (num == 4)
                       {
                         cout << "Hamburger is another form of steak. :-)nn";
                       }

                       else if (num == 5)
                       {
                         cout << "Finally, a vegitarian is in the house!nn";
                       }

                       else
                       {
                         cout << "Invalid number, please enter a number"
                            << " from the entrees above.nn";
                       }
Screenshot
                     http://eglobiotraining.com

/
    *=====================[output]================
    ======================= MENU 1. Lobster 2. Steak
    3. Turkey 4. Hamberger 5. Vegetarian Choose your
    dinner entree: 5 Finally, a vegitarian is in the house!
    Press any key to continue . . .
    ============================[output
    2]================================ MENU 1.
    Lobster 2. Steak 3. Turkey 4. Hamberger 5. Vegetarian
    Choose your dinner entree: 0 Invalid number, please
    enter a number from the entrees above. Press any key
    to continue . . .
    =============================================
    =========================*/
Switch Example 5
                                                  http://eglobiotraining.com



#include <stdlib.h>
#include <stdio.h>

int main(void) {
  int n;
  printf("Please enter a number: ");
  scanf("%d", &n);
  switch (n) {
    case 1: {
      printf("n is equal to 1!n");
      break;
    }
    case 2: {
      printf("n is equal to 2!n");
      break;
    }
    case 3: {
      printf("n is equal to 3!n");
      break;
    }
    default: {
      printf("n isn't equal to 1, 2, or 3.n");
      break;
    }
  }
  system("PAUSE");
  return 0;
}
Screenshot
http://eglobiotraining.com
http://eglobiotraining.com
http://eglobiotraining.com
Submitted to:
Professor Erwin Globio
http://eglobiotraining.com/

More Related Content

Viewers also liked

Viewers also liked (10)

Ramon cabanillas
Ramon cabanillasRamon cabanillas
Ramon cabanillas
 
Ro flyer 10_blaetterkatalog_150
Ro flyer 10_blaetterkatalog_150Ro flyer 10_blaetterkatalog_150
Ro flyer 10_blaetterkatalog_150
 
Pembangunan Pertanian
Pembangunan PertanianPembangunan Pertanian
Pembangunan Pertanian
 
ユーザー体験設計を軸にすすめるサービスデザイン
ユーザー体験設計を軸にすすめるサービスデザインユーザー体験設計を軸にすすめるサービスデザイン
ユーザー体験設計を軸にすすめるサービスデザイン
 
Powerpoint loop examples a
Powerpoint loop examples aPowerpoint loop examples a
Powerpoint loop examples a
 
Curriculum
CurriculumCurriculum
Curriculum
 
Persamaan dan rumus kimia (ii)
Persamaan dan rumus kimia (ii)Persamaan dan rumus kimia (ii)
Persamaan dan rumus kimia (ii)
 
Strategic management project (1)
Strategic management project (1)Strategic management project (1)
Strategic management project (1)
 
Accident
AccidentAccident
Accident
 
Undang undang & anda
Undang undang & andaUndang undang & anda
Undang undang & anda
 

Similar to Powerpoint switch1 (8)

Ramirez slideshow
Ramirez slideshowRamirez slideshow
Ramirez slideshow
 
Lab # 3
Lab # 3Lab # 3
Lab # 3
 
Project in programming
Project in programmingProject in programming
Project in programming
 
Algoritma 5 november wiwik p.l
Algoritma 5 november wiwik p.lAlgoritma 5 november wiwik p.l
Algoritma 5 november wiwik p.l
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Programming - Marla Fuentes
Programming - Marla FuentesProgramming - Marla Fuentes
Programming - Marla Fuentes
 
Ch4
Ch4Ch4
Ch4
 
Programa de Detección de Valor de una Resistencia de Carbón en C++
Programa de Detección de Valor de una Resistencia de Carbón en C++Programa de Detección de Valor de una Resistencia de Carbón en C++
Programa de Detección de Valor de una Resistencia de Carbón en C++
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

Powerpoint switch1

  • 1. Switch example 1 http://eglobiotraining.com. #include <iostream> using namespace std; int main(void) { char grade; cout << "Enter your grade: "; cin >> grade; switch (grade) { case 'a':case 'A': cout << "Your average must be between 90 - 100" << endl; break; case 'b': case 'B': cout << "Your average must be between 80 - 89" << endl; break; case 'c': case 'C': cout << "Your average must be between 70 - 79" << endl; break; case 'd': case 'D': cout << "Your average must be between 60 - 69" << endl; break; default: cout << "Your average must be below 60" << endl; } return 0; }
  • 2. Screenshot http://eglobiotraining.com Enter your grade: 1 Your average must be below 60
  • 3. Switch example 2 • #include <iostream> http://eglobiotraining.com • using namespace std; • int main() • { • int choice; • cout << "MENUnn"; • cout << "1." << "t" << "Lobstern"; • cout << "2." << "t" << "Steakn"; • cout << "3." << "t" << "Turkeyn"; • cout << "4." << "t" << "Hambergern"; • cout << "5." << "t" << "Vegetariannn"; • cout << "Choose your dinner entree: "; • cin >> choice; • cout << endl; • switch (choice) • { • case 1: cout << "Lobster is my favorite! Dig in!nn"; • break; • case 2: cout << "Yummy! Steak is great...n" • << "but limit yourself to once a week," << endl • << "or risk the chance of high cholesterol!nn"; • break; • case 3: cout << "Turkey is healthier than steak! ...Enjoy!nn"; • break; • case 4: cout << "Hamburger is another form of steak. :-)nn"; • break; • case 5: cout << "Finally, a vegitarian is in the house!nn"; • break; • default: cout << "Invalid number, please enter a number" • << " from the entrees above.nn"; • break; • } • return 0; • }
  • 4. Screenshot http://eglobiotraining.com MENU 1. Lobster 2. Steak 3. Turkey 4. Hamberger 5. Vegetarian Choose your dinner entree: 2 Yummy! Steak is great... but limit yourself to once a week, or risk the chance of high cholesterol!
  • 5. Switch example 3 http://eglobiotraining.com #include <iostream> using namespace std; int main() { char letter; cout << "A)tHouse MDn" << "B)tAmerican Idlen" << "C)tFamily Guynn"; cout << "What TV show do you like (Enter A, B, C)?: "; cin >> letter; cout << endl; switch (toupper(letter)) { case 'A' : cout << "Dr. House is a radical doctor!nn"; break; case 'B' : cout << "Wannabe singers!nn"; break; case 'C' : cout << "One of the craziest cartoons Ive ever seen.nn"; break; default: cout << "Invalid choice.nn"; break; } return 0; }
  • 6. Screenshot http://eglobiotraining.com / *============================[output]======== ========================= A) House MD B) American Idle C) Family Guy What TV show do you like (Enter A, B, C)?: a Dr. House is a radical doctor! Press any key to continue . . . =============================[output 2]================================ A) House MD B) American Idle C) Family Guy What TV show do you like (Enter A, B, C)?: z Invalid choice. Press any key to continue . . . ============================================ ==========================*/
  • 7. Switch example 4 http://eglobiotraining.com #include <iostream> using namespace std; int main() { int num; cout << "MENUnn"; cout << "1." << "t" << "Lobstern"; cout << "2." << "t" << "Steakn"; cout << "3." << "t" << "Turkeyn"; cout << "4." << "t" << "Hambergern"; cout << "5." << "t" << "Vegetariannn"; cout << "Choose your dinner entree: "; cin >> num; cout << endl; if (num == 1) { cout << "Lobster is my favorite! Dig in!nn"; } else if (num == 2) { cout << "Yummy! Steak is great...n" << "but limit yourself to once a week,n" << "or risk the chance of high cholesterol!nn"; } else if (num == 3) { cout << "Turkey is healthier than steak! ...Enjoy!nn"; } else if (num == 4) { cout << "Hamburger is another form of steak. :-)nn"; } else if (num == 5) { cout << "Finally, a vegitarian is in the house!nn"; } else { cout << "Invalid number, please enter a number" << " from the entrees above.nn"; }
  • 8. Screenshot http://eglobiotraining.com / *=====================[output]================ ======================= MENU 1. Lobster 2. Steak 3. Turkey 4. Hamberger 5. Vegetarian Choose your dinner entree: 5 Finally, a vegitarian is in the house! Press any key to continue . . . ============================[output 2]================================ MENU 1. Lobster 2. Steak 3. Turkey 4. Hamberger 5. Vegetarian Choose your dinner entree: 0 Invalid number, please enter a number from the entrees above. Press any key to continue . . . ============================================= =========================*/
  • 9. Switch Example 5 http://eglobiotraining.com #include <stdlib.h> #include <stdio.h> int main(void) { int n; printf("Please enter a number: "); scanf("%d", &n); switch (n) { case 1: { printf("n is equal to 1!n"); break; } case 2: { printf("n is equal to 2!n"); break; } case 3: { printf("n is equal to 3!n"); break; } default: { printf("n isn't equal to 1, 2, or 3.n"); break; } } system("PAUSE"); return 0; }
  • 13. Submitted to: Professor Erwin Globio http://eglobiotraining.com/