SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Lecture04(Control Structure PART-I)
June 22, 2010
      Today's Outline
         Decision making statements in C
           •   Simple if statement
           •   if_else statement
           •   else_if ladder
           •   nested if_else statement
           •   switch statement
           •   goto statement



 Md. Mahbub Alam         Structured Programming Language   1
                                    (CSE-1121)
Simple if Statement
Format:
                  If ( test condition )
                      statements;


                  scanf( “ %f “ , &marks );
                  if( marks >= 80 )
                     printf( "Yes, the student get A+“ );




Md. Mahbub Alam           Structured Programming Language   2
                                     (CSE-1121)
if_else Statement
Format:
                  if ( test condition )
                       statements;
                  else
                       statements;


                  if( num % 2 == 0 )
                     printf( “Even number“ );
                  else
                     printf( “Odd number” );



Md. Mahbub Alam           Structured Programming Language   3
                                     (CSE-1121)
else_if ladder Statement
Format:
        if(condition 1)                  if( marks > 79 )
              statements;                    printf( " Honours “ );
       else if(condition 2)              else if( marks > 59 )
              statements;                    printf( " First Division “ );
       else if(condition)                else if( marks > 49 )
              statements;                    printf( " Second Division “ );
       .............. ..                 else if( marks > 39 )
       .............. ..                     printf( " Third Division “ );
       else if(condition n)              else
              statements;                    printf(" Fail ");
       else
            default statement;



 Md. Mahbub Alam         Structured Programming Language                      4
                                    (CSE-1121)
nested if_else Statement
Format:
      if ( condition )                if(a>b)
          if ( condition )            {
                                          if(a>c)
                statement1;                 printf("a is the largest:%d",a);
          else                            else
                statement2;                 printf("c is the largest:%d",c) ;
      else                            }
           statement3                 else
                                      {
                                          if(c>b)
                                            printf("c is the largest:%d",c);
                                          else
                                            printf("b is the largest:%d",b) ;
                                      }

 Md. Mahbub Alam       Structured Programming Language                          5
                                  (CSE-1121)
switch Statement
                                            index=marks/10;
Format:                                      switch (index)
                                             {
     Switch ( expression )                     case 10:
                                               case 9:
     {
                                               case 8:
         case constant1:                         printf(" Honours ");
                statements;                      break;
                break;                         case 7:
                                               case 6:
         case constant2:
                                                 printf(“ First Division ");
                statements;                      break;
                break;                         case 5:
          ...............                        printf(“ Second Division ");
                                                 break;
          ...............
                                               case 4:
          default:                               printf(“ Third Division ");
               statements;                       break;
               break;                          default:
      }                                          printf( “ Fail ");
                                                 break;
                                             }
 Md. Mahbub Alam        Structured Programming Language                         6
                                   (CSE-1121)
goto Statement
Format:
       goto label;               main()
        .........                {
        .........                   double x,y;
       label:                       read:
         statements;                scanf("%lf",&x);
                                    if(x<0)
       label:
                                      goto read;
        statements;
                                    y=sqrt(x);
         .........
                                    printf("%lf",y);
         .........
                                 }
       goto label;


 Md. Mahbub Alam        Structured Programming Language   7
                                   (CSE-1121)
Any Question?




Md. Mahbub Alam   Structured Programming Language   8
                             (CSE-1121)
Thank You All




Md. Mahbub Alam     Structured Programming Language   9
                               (CSE-1121)

Weitere ähnliche Inhalte

Was ist angesagt?

Decision making statements in C
Decision making statements in CDecision making statements in C
Decision making statements in CRabin BK
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)heoff
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Ismar Silveira
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
Joji ilagan career center foundation6final
Joji ilagan career center foundation6finalJoji ilagan career center foundation6final
Joji ilagan career center foundation6finalbluejayjunior
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructionsProdip Ghosh
 
C operators
C operatorsC operators
C operatorssrmohan06
 
Control Structure in C
Control Structure in CControl Structure in C
Control Structure in CNeel Shah
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docxJavvajiVenkat
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrolsteach4uin
 
C++ STATEMENTS
C++ STATEMENTS C++ STATEMENTS
C++ STATEMENTS Prof Ansari
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcqParthipan Parthi
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ â €
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetitionHattori Sidek
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements Tarun Sharma
 

Was ist angesagt? (19)

Decision making statements in C
Decision making statements in CDecision making statements in C
Decision making statements in C
 
4. loop
4. loop4. loop
4. loop
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
Joji ilagan career center foundation6final
Joji ilagan career center foundation6finalJoji ilagan career center foundation6final
Joji ilagan career center foundation6final
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructions
 
C operators
C operatorsC operators
C operators
 
Control Structure in C
Control Structure in CControl Structure in C
Control Structure in C
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docx
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
C++ STATEMENTS
C++ STATEMENTS C++ STATEMENTS
C++ STATEMENTS
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 

Ă„hnlich wie Lecture04(control structure part i)

CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptSanjjaayyy
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptxeaglesniper008
 
LET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSLET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSKavyaSharma65
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)jakejakejake2
 
Conditional statements
Conditional statementsConditional statements
Conditional statementsNabishaAK
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScriptJohannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScriptJohannes Hoppe
 
Perl Intro 4 Debugger
Perl Intro 4 DebuggerPerl Intro 4 Debugger
Perl Intro 4 DebuggerShaun Griffith
 
Decision Making and Branching
Decision Making and BranchingDecision Making and Branching
Decision Making and BranchingMunazza-Mah-Jabeen
 
Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)chk49
 
control stucture in c language
control stucture in c language control stucture in c language
control stucture in c language abdulahi45
 
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)securityxploded
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdfDurga Padma
 
Final Exam in FNDPRG
Final Exam in FNDPRGFinal Exam in FNDPRG
Final Exam in FNDPRGflorimaycasakit
 

Ă„hnlich wie Lecture04(control structure part i) (20)

L3 control
L3 controlL3 control
L3 control
 
Lecture05(control structure part ii)
Lecture05(control structure part ii)Lecture05(control structure part ii)
Lecture05(control structure part ii)
 
Session 3
Session 3Session 3
Session 3
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptx
 
LET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSLET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERS
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
Perl Intro 4 Debugger
Perl Intro 4 DebuggerPerl Intro 4 Debugger
Perl Intro 4 Debugger
 
Decision Making and Branching
Decision Making and BranchingDecision Making and Branching
Decision Making and Branching
 
Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)
 
control stucture in c language
control stucture in c language control stucture in c language
control stucture in c language
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
What is c
What is cWhat is c
What is c
 
Final Exam in FNDPRG
Final Exam in FNDPRGFinal Exam in FNDPRG
Final Exam in FNDPRG
 

KĂĽrzlich hochgeladen

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
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
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...Pooja Nehwal
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

KĂĽrzlich hochgeladen (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
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
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Lecture04(control structure part i)

  • 1. Lecture04(Control Structure PART-I) June 22, 2010 Today's Outline Decision making statements in C • Simple if statement • if_else statement • else_if ladder • nested if_else statement • switch statement • goto statement Md. Mahbub Alam Structured Programming Language 1 (CSE-1121)
  • 2. Simple if Statement Format: If ( test condition ) statements; scanf( “ %f “ , &marks ); if( marks >= 80 ) printf( "Yes, the student get A+“ ); Md. Mahbub Alam Structured Programming Language 2 (CSE-1121)
  • 3. if_else Statement Format: if ( test condition ) statements; else statements; if( num % 2 == 0 ) printf( “Even number“ ); else printf( “Odd number” ); Md. Mahbub Alam Structured Programming Language 3 (CSE-1121)
  • 4. else_if ladder Statement Format: if(condition 1) if( marks > 79 ) statements; printf( " Honours “ ); else if(condition 2) else if( marks > 59 ) statements; printf( " First Division “ ); else if(condition) else if( marks > 49 ) statements; printf( " Second Division “ ); .............. .. else if( marks > 39 ) .............. .. printf( " Third Division “ ); else if(condition n) else statements; printf(" Fail "); else default statement; Md. Mahbub Alam Structured Programming Language 4 (CSE-1121)
  • 5. nested if_else Statement Format: if ( condition ) if(a>b) if ( condition ) { if(a>c) statement1; printf("a is the largest:%d",a); else else statement2; printf("c is the largest:%d",c) ; else } statement3 else { if(c>b) printf("c is the largest:%d",c); else printf("b is the largest:%d",b) ; } Md. Mahbub Alam Structured Programming Language 5 (CSE-1121)
  • 6. switch Statement index=marks/10; Format: switch (index) { Switch ( expression ) case 10: case 9: { case 8: case constant1: printf(" Honours "); statements; break; break; case 7: case 6: case constant2: printf(“ First Division "); statements; break; break; case 5: ............... printf(“ Second Division "); break; ............... case 4: default: printf(“ Third Division "); statements; break; break; default: } printf( “ Fail "); break; } Md. Mahbub Alam Structured Programming Language 6 (CSE-1121)
  • 7. goto Statement Format: goto label; main() ......... { ......... double x,y; label: read: statements; scanf("%lf",&x); if(x<0) label: goto read; statements; y=sqrt(x); ......... printf("%lf",y); ......... } goto label; Md. Mahbub Alam Structured Programming Language 7 (CSE-1121)
  • 8. Any Question? Md. Mahbub Alam Structured Programming Language 8 (CSE-1121)
  • 9. Thank You All Md. Mahbub Alam Structured Programming Language 9 (CSE-1121)