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 design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

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