SlideShare a Scribd company logo
1 of 13
What is a Switch Case?
0 Switch Case is a type of selection control mechanism that
 exists in most imperative programming languages such
 as Pascal, Ada, C/C++, C#, Java, and so on. It is also
 included in several other types of languages. Its purpose is
 to allow the value of a variable or expression to control
 the flow of program execution via a multiway branch (or
 "goto", one of several labels). The main reasons for using a
 switch include improving clarity, by reducing otherwise
 repetitive coding, and (if the heuristics permit) also
 offering the potential for faster execution through
 easier compiler optimization in many case.
Examples:
Example #1:                           break;
                                    case 'D' :
#include <iostream>                   cout << "You passed" << endl;
using namespace std;                  break;
                                    case 'F' :
int main ()                           cout << "Better try again" << endl;
{                                     break;
  // local variable declaration:    default :
  char grade = 'D';                   cout << "Invalid grade" << endl;
                                    }
 switch(grade)                      cout << "Your grade is " << grade << endl;
 {
 case 'A' :                        System (“pause”);
   cout << "Excellent!" << endl;    return 0;
   break;                          }
 case 'B' :
 case 'C' :
   cout << "Well done" << endl;
Example #2:                                                }

#include <iostream>                                         cout << "Of course I had nothing to
 using namespace std;                            do with the grade.";
                                                            cout << "nThe professor was really
  int main ()                                    off the wall.n";
  {
                                                 system ("pause");
           char letGrad, ch;                     return 0;
           cout << "Please enter a character: ";
           cin >> letGrad;                       }
           switch (letGrad)
            {
           case 'A': cout << "The numerical
grade is between 90 and 100"; break;
           case 'B': cout << "The numerical
grade is between 80 and 89.9"; break;
           case 'C': cout << "The numerical
grade is between 70 and 79.9"; break;
           case 'D': cout << "How are you going
to explain this one?"; break;
Example #3:                               break;

#include <iostream>                       case 'F':
using namespace std;                      person = "female";
int main ( )                              break;
{
  string person ;                         case 'f':
char gender ;                             person ="female";
cout << "Please enter your gender !n";   break;
cin >> gender;                            default:
switch (gender)                           person = "unknown";
{    case 'm':                            }
person = "male" ;                         cout << person << endl;
break;
                                          system ("pause");
case 'M':                                 return 0;
person = "male";                          }
Example #4:                                             break;
                                                           default: cout << "Too large!n";
#include <iostream.h>                                   break;
int main()                                          }
{                                                   cout << "nn";
      unsigned short int number;
      cout << "Enter a number between 1 and 5: ";   system("pause");
      cin >> number;                                 return 0;
      switch (number)
      {                                             }
      case 0: cout << "Too small, sorry!";

  break;
     case 5: cout << "Good job!n";
     break;
     case 4: cout << "Nice Pick!n";
     break;
     case 3: cout << "Excellent!n";
     break;
     case 2: cout << "Masterful!n";
     break;
     case 1: cout << "Incredible!n";
What are Loops?
0 Loops are used to repeat a block of code. Being able to
 have your program repeatedly execute a block of code is
 one of the most basic but useful tasks in programming --
 many programs or websites that produce extremely
 complex output (such as a message board) are really only
 executing a single task many times. (They may be executing
 a small number of tasks, but in principle, to produce a list
 of messages only requires repeating the operation of
 reading in some data and displaying it.) Now, think about
 what this means: a loop lets you write a very simple
 statement to produce a significantly greater result simply
 by repetition.
Examples:
Example #1:
#include <iostream>

using namespace std;

int main()
{
  int x;

    x = 0;
    do {

     cout<<"Hello, world!n";
    } while ( x != 0 );
    cin.get();
}
Example #2:

#include<iostream>
#include<string>
int main()
{

using namespace std;
string password, happiness;
happiness="happiness";

cout<<"Enter the correct password..n"<<endl;
do{
cout<<"Enter the correct password to obtain surprise: ";
cin>> password;
}

while (password!=happiness);
cout<<"You've got it!"<<endl;

system("pause");
return (0);
}
Example #3:                   while ( time < 1 || time > 10) endl;
                                     { cout << "Must enter
#include <iostream>           between 1 and 10 seconds,                  }
#include <cmath>              please re-enter.n";                   system ("pause");
using namespace std;                   time =                            return 0;
                              fallingdistance();
                                                                   }
int fallingdistance();                                             int fallingdistance ()
                                     }
                                                                   {
int main()                                                               int seconds;
                                     cout <<"nSeconds
{                                           falling distancen";         cin >> seconds;
     int count = 1 ;                 cout <<"---------------------       return seconds;
     int time;                ------------------n";               }
     double distance ;
     cout << "Please                for ( count = 1; count <=
entertime in 1 through 10     time; count++)
seconds.nn";                      {
                                          distance = .5 * 9.8 *
  time = fallingdistance();   pow(time, 2.0);
                                          cout << count << "
                              " << distance <<" meters"<<
Submitted to:

Mr. Edwin Globio
http://eglobiotraining.com




                  Thank you and God bless!
         http://www.slideshare.net/mfuentessss

More Related Content

What's hot

The Ring programming language version 1.10 book - Part 87 of 212
The Ring programming language version 1.10 book - Part 87 of 212The Ring programming language version 1.10 book - Part 87 of 212
The Ring programming language version 1.10 book - Part 87 of 212Mahmoud Samir Fayed
 
Introducere In Java Jx
Introducere In Java JxIntroducere In Java Jx
Introducere In Java Jxdanielnastase
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Lin Yo-An
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorialnikomatsakis
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02nikomatsakis
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-CNissan Tsafrir
 
Powerpoint loop examples a
Powerpoint loop examples aPowerpoint loop examples a
Powerpoint loop examples ajaypeebala
 
C++ Programming - 12th Study
C++ Programming - 12th StudyC++ Programming - 12th Study
C++ Programming - 12th StudyChris Ohk
 
Bluespec Tutorial Helloworld
Bluespec Tutorial HelloworldBluespec Tutorial Helloworld
Bluespec Tutorial HelloworldStanley Ho
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramMeenakshi Devi
 
C++ Programming - 9th Study
C++ Programming - 9th StudyC++ Programming - 9th Study
C++ Programming - 9th StudyChris Ohk
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/ProxyPeter Eisentraut
 
Aspect Mining for Large Systems
Aspect Mining for Large SystemsAspect Mining for Large Systems
Aspect Mining for Large SystemsThomas Zimmermann
 
Oops pramming with examples
Oops pramming with examplesOops pramming with examples
Oops pramming with examplesSyed Khaleel
 

What's hot (20)

The Ring programming language version 1.10 book - Part 87 of 212
The Ring programming language version 1.10 book - Part 87 of 212The Ring programming language version 1.10 book - Part 87 of 212
The Ring programming language version 1.10 book - Part 87 of 212
 
Introducere In Java Jx
Introducere In Java JxIntroducere In Java Jx
Introducere In Java Jx
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
Ns2programs
Ns2programsNs2programs
Ns2programs
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorial
 
Email Using Plsql
Email Using PlsqlEmail Using Plsql
Email Using Plsql
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-C
 
Powerpoint loop examples a
Powerpoint loop examples aPowerpoint loop examples a
Powerpoint loop examples a
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
C++ Programming - 12th Study
C++ Programming - 12th StudyC++ Programming - 12th Study
C++ Programming - 12th Study
 
Bluespec Tutorial Helloworld
Bluespec Tutorial HelloworldBluespec Tutorial Helloworld
Bluespec Tutorial Helloworld
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proram
 
C++ Programming - 9th Study
C++ Programming - 9th StudyC++ Programming - 9th Study
C++ Programming - 9th Study
 
Lab
LabLab
Lab
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
 
Aspect Mining for Large Systems
Aspect Mining for Large SystemsAspect Mining for Large Systems
Aspect Mining for Large Systems
 
Oops pramming with examples
Oops pramming with examplesOops pramming with examples
Oops pramming with examples
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 

Viewers also liked

Look book
Look bookLook book
Look bookjkerher
 
orquestres, orquesta, cambra, banda, simfònica
orquestres, orquesta, cambra, banda, simfònicaorquestres, orquesta, cambra, banda, simfònica
orquestres, orquesta, cambra, banda, simfònicamonguko
 
Ct 2 evidens band 1&3 tahun 3
Ct 2 evidens band 1&3 tahun 3Ct 2 evidens band 1&3 tahun 3
Ct 2 evidens band 1&3 tahun 3Thomas Ee
 
Presentation1tmk modulgurumurid
Presentation1tmk modulgurumuridPresentation1tmk modulgurumurid
Presentation1tmk modulgurumuridThomas Ee
 
Kh pksr 1 2012
Kh pksr 1 2012Kh pksr 1 2012
Kh pksr 1 2012amirqayyum
 
repeticions
repeticionsrepeticions
repeticionsmonguko
 
Kumpulan 4 sains
Kumpulan 4 sainsKumpulan 4 sains
Kumpulan 4 sainsThomas Ee
 

Viewers also liked (9)

Look book
Look bookLook book
Look book
 
orquestres, orquesta, cambra, banda, simfònica
orquestres, orquesta, cambra, banda, simfònicaorquestres, orquesta, cambra, banda, simfònica
orquestres, orquesta, cambra, banda, simfònica
 
Ct 2 evidens band 1&3 tahun 3
Ct 2 evidens band 1&3 tahun 3Ct 2 evidens band 1&3 tahun 3
Ct 2 evidens band 1&3 tahun 3
 
Presentation1tmk modulgurumurid
Presentation1tmk modulgurumuridPresentation1tmk modulgurumurid
Presentation1tmk modulgurumurid
 
Kh pksr 1 2012
Kh pksr 1 2012Kh pksr 1 2012
Kh pksr 1 2012
 
Trial
TrialTrial
Trial
 
repeticions
repeticionsrepeticions
repeticions
 
Kumpulan 4 sains
Kumpulan 4 sainsKumpulan 4 sains
Kumpulan 4 sains
 
Zvit presentation 01
Zvit presentation 01Zvit presentation 01
Zvit presentation 01
 

Similar to Programming - Marla Fuentes

c++ Lecture 4
c++ Lecture 4c++ Lecture 4
c++ Lecture 4sajidpk92
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Final requirement in programming niperos
Final requirement in programming   niperosFinal requirement in programming   niperos
Final requirement in programming niperosmarkings17
 
Final requirement (2)
Final requirement (2)Final requirement (2)
Final requirement (2)Anjie Sengoku
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! aleks-f
 
Final requirement in programming vinson
Final requirement in programming  vinsonFinal requirement in programming  vinson
Final requirement in programming vinsonmonstergeorge
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3 rohassanie
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 

Similar to Programming - Marla Fuentes (20)

DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
C++ practical
C++ practicalC++ practical
C++ practical
 
c++ Lecture 4
c++ Lecture 4c++ Lecture 4
c++ Lecture 4
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Oop1
Oop1Oop1
Oop1
 
Final requirement in programming niperos
Final requirement in programming   niperosFinal requirement in programming   niperos
Final requirement in programming niperos
 
Final requirement (2)
Final requirement (2)Final requirement (2)
Final requirement (2)
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
Lab # 3
Lab # 3Lab # 3
Lab # 3
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
Final requirement in programming vinson
Final requirement in programming  vinsonFinal requirement in programming  vinson
Final requirement in programming vinson
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
3 rd animation
3 rd animation3 rd animation
3 rd animation
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Opp compile
Opp compileOpp compile
Opp compile
 

Recently uploaded

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
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.pdfNirmal Dwivedi
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 

Programming - Marla Fuentes

  • 1.
  • 2. What is a Switch Case? 0 Switch Case is a type of selection control mechanism that exists in most imperative programming languages such as Pascal, Ada, C/C++, C#, Java, and so on. It is also included in several other types of languages. Its purpose is to allow the value of a variable or expression to control the flow of program execution via a multiway branch (or "goto", one of several labels). The main reasons for using a switch include improving clarity, by reducing otherwise repetitive coding, and (if the heuristics permit) also offering the potential for faster execution through easier compiler optimization in many case.
  • 3. Examples: Example #1: break; case 'D' : #include <iostream> cout << "You passed" << endl; using namespace std; break; case 'F' : int main () cout << "Better try again" << endl; { break; // local variable declaration: default : char grade = 'D'; cout << "Invalid grade" << endl; } switch(grade) cout << "Your grade is " << grade << endl; { case 'A' : System (“pause”); cout << "Excellent!" << endl; return 0; break; } case 'B' : case 'C' : cout << "Well done" << endl;
  • 4. Example #2: } #include <iostream> cout << "Of course I had nothing to using namespace std; do with the grade."; cout << "nThe professor was really int main () off the wall.n"; { system ("pause"); char letGrad, ch; return 0; cout << "Please enter a character: "; cin >> letGrad; } switch (letGrad) { case 'A': cout << "The numerical grade is between 90 and 100"; break; case 'B': cout << "The numerical grade is between 80 and 89.9"; break; case 'C': cout << "The numerical grade is between 70 and 79.9"; break; case 'D': cout << "How are you going to explain this one?"; break;
  • 5. Example #3: break; #include <iostream> case 'F': using namespace std; person = "female"; int main ( ) break; { string person ; case 'f': char gender ; person ="female"; cout << "Please enter your gender !n"; break; cin >> gender; default: switch (gender) person = "unknown"; { case 'm': } person = "male" ; cout << person << endl; break; system ("pause"); case 'M': return 0; person = "male"; }
  • 6. Example #4: break; default: cout << "Too large!n"; #include <iostream.h> break; int main() } { cout << "nn"; unsigned short int number; cout << "Enter a number between 1 and 5: "; system("pause"); cin >> number; return 0; switch (number) { } case 0: cout << "Too small, sorry!"; break; case 5: cout << "Good job!n"; break; case 4: cout << "Nice Pick!n"; break; case 3: cout << "Excellent!n"; break; case 2: cout << "Masterful!n"; break; case 1: cout << "Incredible!n";
  • 7.
  • 8. What are Loops? 0 Loops are used to repeat a block of code. Being able to have your program repeatedly execute a block of code is one of the most basic but useful tasks in programming -- many programs or websites that produce extremely complex output (such as a message board) are really only executing a single task many times. (They may be executing a small number of tasks, but in principle, to produce a list of messages only requires repeating the operation of reading in some data and displaying it.) Now, think about what this means: a loop lets you write a very simple statement to produce a significantly greater result simply by repetition.
  • 9. Examples: Example #1: #include <iostream> using namespace std; int main() { int x; x = 0; do { cout<<"Hello, world!n"; } while ( x != 0 ); cin.get(); }
  • 10. Example #2: #include<iostream> #include<string> int main() { using namespace std; string password, happiness; happiness="happiness"; cout<<"Enter the correct password..n"<<endl; do{ cout<<"Enter the correct password to obtain surprise: "; cin>> password; } while (password!=happiness); cout<<"You've got it!"<<endl; system("pause"); return (0); }
  • 11. Example #3: while ( time < 1 || time > 10) endl; { cout << "Must enter #include <iostream> between 1 and 10 seconds, } #include <cmath> please re-enter.n"; system ("pause"); using namespace std; time = return 0; fallingdistance(); } int fallingdistance(); int fallingdistance () } { int main() int seconds; cout <<"nSeconds { falling distancen"; cin >> seconds; int count = 1 ; cout <<"--------------------- return seconds; int time; ------------------n"; } double distance ; cout << "Please for ( count = 1; count <= entertime in 1 through 10 time; count++) seconds.nn"; { distance = .5 * 9.8 * time = fallingdistance(); pow(time, 2.0); cout << count << " " << distance <<" meters"<<
  • 12.
  • 13. Submitted to: Mr. Edwin Globio http://eglobiotraining.com Thank you and God bless! http://www.slideshare.net/mfuentessss