SlideShare une entreprise Scribd logo
1  sur  30
FINAL REQUIREMENT




Reena R. Perez




                    http://eglobiotraining.com/
http://eglobiotraining.com/
   In programming, a switch, case, select
    or inspect statement is a type of
    selection control mechanism that exists
    in most imperative programming
    languages such as
    Pascal, Ada, C/C++, C# programming
    language , Java, and so on.




                                    http://eglobiotraining.com/
It is also included in several other types of
programming 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 cases.

                                        http://eglobiotraining.com/
   char key;
 C#
 In C# programming, every case            printf("Enter an arithmetic operatorn");
                                           scanf("%c",&key);
  block that contains any
  statements must have a                   switch (key)
  reachable end point, or triggers a       {
  compilation error.In                       case '+':
                                               add();
  programming usually, this is a
                                               break;
  break statement, but any jump
  statement can be used – such as              case '-':
  return, goto or throw – or the                 subtract();
                                                 break;
  switch can simply end with an
  infinite loop. Case fall-through is          case '*':
  only permitted when there are no               multiply();
  statements between one case                    break;

  statement and the next. If fall-
                                               case '/':
  through is otherwise desired, it               divide();
  must be made explicit with the                 break;
  goto case construct. C#
                                               default:
  programming also allows the
                                                 printf("invalid keyn");
  use of non-integer case                        break;
  values, such as Strings.                 }
                                                                       http://eglobiotraining.com/
#include<iostream>
#include<stdlib.h>

using namespace std;
int main ()
{

int number_of_units, tuitionfee, paymentforunits;

cout<< "number of units you are to enroll:nn";
cin>>number_of_units;

paymentforunits=number_of_units*150;
cout<<"payment for units:nn"<<paymentforunits;

tuitionfee=paymentforunits+15%+20;
cout<<"tuition fee:nn"<<tuitionfee;

system("PAUSE");
return 0;

}


                                                    http://eglobiotraining.com/
   Select Case n
                                     Case Is < -5
                                       MsgBox("n is less than -5")
   Visual Basic .NET                Case -4 To -1
                                       MsgBox("n is between -4 and -1")
                                     Case 0
                                       MsgBox("n is 0")
   In programming, Visual           Case 2, 4, 6, 8
    Basic .NET, the switch       
                                 
                                        MsgBox("n is even")
                                      Case 1, 3, 5, 7, 9
    statement is called                MsgBox("n is odd")
    "Select Case                 
                                 
                                      Case Else
                                        MsgBox("only single-digit numbers are
    programming", and fall-      
                                     allowed.", vbCritical)
                                     End Select
    through to later blocks is   

    not supported.               
                                 
                                     Visual FoxPro

    However, ranges and          
                                 
                                     Visual FoxPro:

    various constructs from If      Do Case
    statements are both          
                                 
                                     Case field_1 = "X"
                                      Replace field_b With 1
    supported                       Case field_1 = "Y"
                                     Replace field_b With 2
                                    Case field_1 = "Z"
                                     Replace field_b With 3
                                    Endcase



                                                      http://eglobiotraining.com/
   #include<iostream>
                                           using namespace std;

                                           int main(void)
                                           {

                                           char grade;
   Haskell
                                           cout << "Enter your
                                           grade: ";

                                           cin >> grade;
   Haskell's case
    construct, unlike C-influenced         switch (grade)

    programming languages, has             {
    no fall-through behaviour. It is        case 'A':

    a programming expression               cout << "Your average
    which returns a value, and it          must be between 90 -
                                           100"
    can deconstruct values using
    pattern matching.                      << endl;

                                           break;

                                           case 'B':

                                           cout << "Your average
                                           must be between 80 -
                                           89"

                                           << endl;

                                           break;

                                           case 'C':

                                           cout << "Your average
                                           must be between 70 -    http://eglobiotraining.com/
                                           79"
#include<stdlib.h>
#include<iostream>
using namespace std;

int main()
{
char gender;

cout<<"Enter your Gender.";
cin>>gender;


if (gender == 'M'||gender == 'm')
cout<<"Male";
else
cout<<"Female";
cout<<"nnn";

system("PAUSE");
return 0;
}

                                    http://eglobiotraining.com/
   #include<iostream>
                                   using namespace std;

   Pascal                
                          
                                     int main()
                                     {
                                                   int a;
                                                   cin >> a;
                                                    if ( a <= 10 )
   In                    
                                                   {
    Programming, Pas      
                              10" << 'n';
                                                                     cout << "Below

    cal does not allow    
                          
                                                    }
                                                    else
    “fall through”, but                            {
                                                                    if ( a < 60 )
    has ranges and                                                  {
    comma separated       
                                     cout << "Below 60" << 'n';
    literal lists.        
                                                }
                                                              }

                                                return 0;
                                    }




                                                  http://eglobiotraining.com/
   #include<iostream>
                                    using namespace std;

                                   int main()
                                   {
 Perl                    
                          
                                                  char myinput;
                                                  cin >> myinput;

                                                 switch (myinput)
   Perl 5.10 has a                              {
                                                              case 'a':
    powerful built in     
    switch statement      
                                    cout << "Run program 1n";

    called given, where   
                                    break;
                                                                  case 'b':
    the programming                                                          {
    cases are called      
                                    cout << "Run program 2n";
    when:                 
                                    cout << "Please Waitn";
                          
                                    break;
                                                                             }
                                                                 default:
                          
                                    cout << "Invalid choicen";
                          
                                    break;
                                                 }
                                                 return 0;
                                   }
                                                    http://eglobiotraining.com/
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

int main()
{
float total_purchase=0, purchase_discount = 0, net_bill=0;

cout<<"PLEASE INPUT TOTAL PURCHASE: ";
cin>>total_purchase;

if (total_purchase >=2000)
purchase_discount = total_purchase*0.10;
cout<<"THE DISCOUNT IS:";
cout<<purchase_discount;
net_bill = (total_purchase)-purchase_discount;
cout<<"nYOUR NET BILL IS:";
cout<<net_bill;


system("PAUSE");

return 0;
                                                             http://eglobiotraining.com/
}
http://eglobiotraining.com/
http://eglobiotraining.com/
   In programming, very often when you write code, you want
    the same block of code to run a number of times. You can
    use looping statements in your code to do this.

   In programming, the JavaScript programming have the
    following looping statements:

 While programming- loops through a block of code while a
  condition is true
 Do...while programming- loops through a block of code
  once, and then repeats the loop while a condition is true
 For programming- run statements a specified number of
  times


                                              http://eglobiotraining.com/
   #include <iostream>
   while
                               using namespace std;

                               int main()
   In programming             {
    while statement              int x;
    will execute a               x = 0;
    block of code while          do {
    a condition is true..          // "Hello, world!" is printed at least
                                one time
                                   // even though the condition is
                                false
                                   cout<<"Hello, world!n";
                                 } while ( x != 0 );
                                 cin.get();
                               }

                                             http://eglobiotraining.com/
    Do...while                
                                
                                    /**
                                     ** This example contains a switch statement that performs
                                    ** the same statement for more than one case label.
     In Programming the            **/

      do...while statement         #include <stdio.h>

      will execute a block of      int main(void)
                                   {
      code once, and then it         int month;

      will repeat the loop          /* Read in a month value */
                                    printf("Enter month: ");
      while a condition is          scanf("%d", &month);

      true                          /* Tell what season it falls into */
                                    switch (month)
     The Java                  
                                
                                     {
                                        case 12:
      programming               
                                
                                        case 1:
                                        case 2:
      language also             
                                
                                          printf("month %d is a winter monthn", month);
                                          break;
      provides a do-while             case 3:
      statement, which can      
                                
                                       case 4:
                                       case 5:
      be expressed as           
                                
                                         printf("month %d is a spring monthn", month);
                                         break;
      follows:                        case 6:
                                      case 7:
                                      case 8:
                                        printf("month %d is a summer monthn", month);
                                        break;

                                      case 9:
                                      case 10:
http://eglobiotraining.com/           case 11:
                                        printf("month %d is a fall monthn", month);
                                        break;
   #include <iostream>

                                        using namespace std; // So the program
                                         can see cout and endl
   for
                                        int main()
                                        {
   In programming the “for”              // The loop goes while x < 10, and x
                                         increases by one every loop
    statement will execute a block        for ( int x = 0; x < 10; x++ ) {
    of code a specified number of           // Keep in mind that the loop condition
                                         checks
    times                                   // the conditional statement before it
                                         loops again.
                                            // consequently, when x equals 10 the
                                         loop breaks.
                                            // x is updated before the condition is
                                         checked.
                                            cout<< x <<endl;
                                          }
                                          cin.get();
                                        }




                                                         http://eglobiotraining.com/
   The Infinite Loop:              #include <iostream>
                                     using namespace std; int
   A loop becomes infinite          main () { for( ; ; ) {
    loop if a condition never        printf("This loop will run
    becomes false. The for           forever.n"); } return 0; }
    loop is traditionally used
    for this purpose. Since
    none of the three
    expressions that form the
    for loop are required, you
    can make an endless
    loop by leaving the
    conditional expression
    empty.

                                              http://eglobiotraining.com/
   While Loop             #include <iostream.h>

                            int main(void) {
                            int x = 0;
   In                      int y = 0;
                            bool validNumber = false;
    programming, Fo         while (validNumber == false) {
    r repeating C           cout << "Please enter an integer between 1 and
                            10: ";
    programming             cin >> x;
                            cout << "You entered: " << x << endl << endl;
    statements whiles       if ((x < 1) || (x > 10)) {
    a condition is          cout << "Your value for x is not between 1 and 10!"
                            << endl;
    true,the while          cout << "Please re-enter the number!" << endl <<
                            endl;
    provides a the          }
                            else
    necessary               validNumber = true;
                            }
    mechanism.
                            cout << "Thank you for entering a valid number!"
                            << endl;

                            system("pause");
                            return 0;
                            }                           http://eglobiotraining.com/
 Input : In any programming language input
  means to feed some data into program.
  Programming can be given in the form of file
  or from command line. C programming
  language provides a set of built-in functions to
  read given input and feed it to the program as
  per requirement.
 Output : In any programming language
  output means to display some data on
  screen, printer or in any file. C programming
  language provides a set of built-in functions to
  output required data.

                                   http://eglobiotraining.com/
Professor: Erwin M. Globio

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Reena programming

  • 1. FINAL REQUIREMENT Reena R. Perez http://eglobiotraining.com/
  • 3. In programming, a switch, case, select or inspect statement is a type of selection control mechanism that exists in most imperative programming languages such as Pascal, Ada, C/C++, C# programming language , Java, and so on. http://eglobiotraining.com/
  • 4. It is also included in several other types of programming 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 cases. http://eglobiotraining.com/
  • 5. char key;  C#  In C# programming, every case  printf("Enter an arithmetic operatorn");  scanf("%c",&key); block that contains any statements must have a  switch (key) reachable end point, or triggers a  { compilation error.In  case '+':  add(); programming usually, this is a  break; break statement, but any jump statement can be used – such as  case '-': return, goto or throw – or the  subtract();  break; switch can simply end with an infinite loop. Case fall-through is  case '*': only permitted when there are no  multiply(); statements between one case  break; statement and the next. If fall-  case '/': through is otherwise desired, it  divide(); must be made explicit with the  break; goto case construct. C#  default: programming also allows the  printf("invalid keyn"); use of non-integer case  break; values, such as Strings.  } http://eglobiotraining.com/
  • 6. #include<iostream> #include<stdlib.h> using namespace std; int main () { int number_of_units, tuitionfee, paymentforunits; cout<< "number of units you are to enroll:nn"; cin>>number_of_units; paymentforunits=number_of_units*150; cout<<"payment for units:nn"<<paymentforunits; tuitionfee=paymentforunits+15%+20; cout<<"tuition fee:nn"<<tuitionfee; system("PAUSE"); return 0; } http://eglobiotraining.com/
  • 7. Select Case n  Case Is < -5  MsgBox("n is less than -5")  Visual Basic .NET  Case -4 To -1  MsgBox("n is between -4 and -1")  Case 0  MsgBox("n is 0")  In programming, Visual  Case 2, 4, 6, 8 Basic .NET, the switch   MsgBox("n is even") Case 1, 3, 5, 7, 9 statement is called  MsgBox("n is odd") "Select Case   Case Else MsgBox("only single-digit numbers are programming", and fall-  allowed.", vbCritical) End Select through to later blocks is  not supported.   Visual FoxPro However, ranges and   Visual FoxPro: various constructs from If  Do Case statements are both   Case field_1 = "X" Replace field_b With 1 supported  Case field_1 = "Y"  Replace field_b With 2  Case field_1 = "Z"  Replace field_b With 3  Endcase http://eglobiotraining.com/
  • 8. #include<iostream> using namespace std; int main(void) { char grade;  Haskell cout << "Enter your grade: "; cin >> grade;  Haskell's case construct, unlike C-influenced switch (grade) programming languages, has { no fall-through behaviour. It is case 'A': a programming expression cout << "Your average which returns a value, and it must be between 90 - 100" can deconstruct values using pattern matching. << endl; break; case 'B': cout << "Your average must be between 80 - 89" << endl; break; case 'C': cout << "Your average must be between 70 - http://eglobiotraining.com/ 79"
  • 9.
  • 10. #include<stdlib.h> #include<iostream> using namespace std; int main() { char gender; cout<<"Enter your Gender."; cin>>gender; if (gender == 'M'||gender == 'm') cout<<"Male"; else cout<<"Female"; cout<<"nnn"; system("PAUSE"); return 0; } http://eglobiotraining.com/
  • 11.
  • 12. #include<iostream>  using namespace std;  Pascal   int main() {  int a;  cin >> a; if ( a <= 10 )  In   { Programming, Pas  10" << 'n'; cout << "Below cal does not allow   } else “fall through”, but  {  if ( a < 60 ) has ranges and  { comma separated  cout << "Below 60" << 'n'; literal lists.   } }  return 0;  } http://eglobiotraining.com/
  • 13.
  • 14. #include<iostream>  using namespace std;  int main()  {  Perl   char myinput; cin >> myinput;  switch (myinput)  Perl 5.10 has a  {  case 'a': powerful built in  switch statement  cout << "Run program 1n"; called given, where  break; case 'b': the programming  { cases are called  cout << "Run program 2n"; when:  cout << "Please Waitn";  break;  }  default:  cout << "Invalid choicen";  break;  }  return 0;  } http://eglobiotraining.com/
  • 15.
  • 16. #include<stdlib.h> #include<iostream> #include<stdio.h> #include<conio.h> using namespace std; int main() { float total_purchase=0, purchase_discount = 0, net_bill=0; cout<<"PLEASE INPUT TOTAL PURCHASE: "; cin>>total_purchase; if (total_purchase >=2000) purchase_discount = total_purchase*0.10; cout<<"THE DISCOUNT IS:"; cout<<purchase_discount; net_bill = (total_purchase)-purchase_discount; cout<<"nYOUR NET BILL IS:"; cout<<net_bill; system("PAUSE"); return 0; http://eglobiotraining.com/ }
  • 17.
  • 20. In programming, very often when you write code, you want the same block of code to run a number of times. You can use looping statements in your code to do this.  In programming, the JavaScript programming have the following looping statements:  While programming- loops through a block of code while a condition is true  Do...while programming- loops through a block of code once, and then repeats the loop while a condition is true  For programming- run statements a specified number of times http://eglobiotraining.com/
  • 21. #include <iostream>  while  using namespace std;  int main()  In programming  { while statement  int x; will execute a  x = 0; block of code while  do { a condition is true..  // "Hello, world!" is printed at least one time  // even though the condition is false  cout<<"Hello, world!n";  } while ( x != 0 );  cin.get();  } http://eglobiotraining.com/
  • 22.
  • 23. Do...while   /** ** This example contains a switch statement that performs  ** the same statement for more than one case label.  In Programming the  **/ do...while statement  #include <stdio.h> will execute a block of  int main(void)  { code once, and then it  int month; will repeat the loop  /* Read in a month value */  printf("Enter month: "); while a condition is  scanf("%d", &month); true  /* Tell what season it falls into */  switch (month)  The Java   { case 12: programming   case 1: case 2: language also   printf("month %d is a winter monthn", month); break; provides a do-while  case 3: statement, which can   case 4: case 5: be expressed as   printf("month %d is a spring monthn", month); break; follows:  case 6:  case 7:  case 8:  printf("month %d is a summer monthn", month);  break;  case 9:  case 10: http://eglobiotraining.com/  case 11:  printf("month %d is a fall monthn", month);  break;
  • 24. #include <iostream>  using namespace std; // So the program can see cout and endl  for  int main()  {  In programming the “for”  // The loop goes while x < 10, and x increases by one every loop statement will execute a block  for ( int x = 0; x < 10; x++ ) { of code a specified number of  // Keep in mind that the loop condition checks times  // the conditional statement before it loops again.  // consequently, when x equals 10 the loop breaks.  // x is updated before the condition is checked.  cout<< x <<endl;  }  cin.get();  } http://eglobiotraining.com/
  • 25.
  • 26. The Infinite Loop:  #include <iostream> using namespace std; int  A loop becomes infinite main () { for( ; ; ) { loop if a condition never printf("This loop will run becomes false. The for forever.n"); } return 0; } loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty. http://eglobiotraining.com/
  • 27.
  • 28. While Loop  #include <iostream.h> int main(void) { int x = 0;  In int y = 0; bool validNumber = false; programming, Fo while (validNumber == false) { r repeating C cout << "Please enter an integer between 1 and 10: "; programming cin >> x; cout << "You entered: " << x << endl << endl; statements whiles if ((x < 1) || (x > 10)) { a condition is cout << "Your value for x is not between 1 and 10!" << endl; true,the while cout << "Please re-enter the number!" << endl << endl; provides a the } else necessary validNumber = true; } mechanism. cout << "Thank you for entering a valid number!" << endl; system("pause"); return 0; } http://eglobiotraining.com/
  • 29.  Input : In any programming language input means to feed some data into program. Programming can be given in the form of file or from command line. C programming language provides a set of built-in functions to read given input and feed it to the program as per requirement.  Output : In any programming language output means to display some data on screen, printer or in any file. C programming language provides a set of built-in functions to output required data. http://eglobiotraining.com/