SlideShare a Scribd company logo
Prepared by: Mrs. Nurul Zakiah Binti Zamri Tan
CONTROL
STATEMENT
TYPE OF CONTROL STATEMENT
C support 3 kinds of control structure:
sequential
selective
iterative
statement that is used to alter the
continuous sequential execution of
statements
sequential
no branching, looping or have any
decision making in the statement
A series of coding.
Source code is execute one after and after.
CONTROL STATEMENT ??
Use to control the flow of the source code/programming
Key to write a structured program where CS can :
Reduce complexity
Improve clarity.
Facilitate debugging and modifying
Technique to organize a program
Operation is simple to trace
ADVATAGES OF CONTROL STATEMENT
Structures are easier to define in flowcharts
Structure programming increases programmer's
productivity
CONTROL STATEMENT
Simple if statement
If else statement
If-else if ladder statement
Switch case statement
go to statement for statement
While statement
do-while
Unconditional Conditional Looping
If statement
If (test condition)
{
Statement block;
}
Next statement;
GENERAL FORM
#include <stdio.h>
#include <conio.h>
int main (void)
{
int num1;
int num2;
printf (“Please Enter 2 numbers”);
scanf(“%d%d”, &num1,&num2);
If (num1== num2)
{
printf(“There are equal”);
}
getch();
}
EXAMPLE
To execute one statement or
group of statements for
particular condition
If –else-statement
If (test condition)
{
Statement block-1;
}
else
{
Statement block-2
}
Next statement;
GENERAL FORM
#include <stdio.h>
void main()
{
int mark;
printf (“Please Enter mark”);
scanf( “%d”, &mark);
If (mark=>39)
{
printf(“Pass”);
}
else
{
printf(“Fail”);
}
getch();
}
EXAMPLE
To execute one group of
statements if the test condition is
true or other group if the test
condition is false
If else.. ladder statement
If (test condition-1)
{
Statement block-1;
}
Else if (test condition-2)
{
Statement block-2;
}
…
…
Else if (test condition-n)
{
Statement block-n;
}
Else
Default statement;
Next statement;
GENERAL FORM
To take multiple decision. This
statement is form by joining
if..else statement.
If one condition is false, it
checks for the next condition
and so on. When all the
conditions are false, then else
block is executed
#include<stdio.h>
#include<string.h>
void main()
{
int n;
printf(" Enter 1 to 3 to select your pet");
scanf("%d",&n);
if(n==1)
{
printf("You pet is a tiger");
}
else if(n==2)
{
printf("You pet is a sugar glider");
}
else if(n==3)
{
printf("You pet is a cow");
}
else
{
printf("No pet selected"); }
getch();
}
EXAMPLE
If else.. ladder statement
switch statement
switch (expression)
{
case value1:
Statement block-1:
break;
case value2:
Statement block-2:
break;
…
.. .
case value-n:
statement block-n:
break;
default:
default statement;
break;
}
Next statement
GENERAL FORM
Alternative to if else if ..ladder
statement
to execute a block of code
based on selection from multiple
choices.
C switch statement is a multiway
decisions that tests whether a
variable or expression matches
one of a number of constant
integer values, and branches
accordingly.
'break' is a statement. It is most
commonly used with the switch
statement. 'break' statement
stops the execution within the
switch statement and exits from
the switch statement.
#include <stdio.h>
main()
{
int Grade;
choose:
printf(“Please insert your grade A, B, C, D, E,
or F”);
scanf("%d",&Grade);
switch( Grade )
{
case 'A' :
printf( "Excellentn" );
break;
case 'B' :
printf( "Goodn" );
break;
case 'C' :
printf( "OKn" );
break;
EXAMPLE
case 'D' :
printf( "Mmmmm....n" );
break;
case 'F' :
printf( "You must do better than
thisn" );
break;
default :
printf( "What is your grade anyway?n"
); go to choose; break;
}
getch();
}
goto statement
goto label:
GENERAL FORM
Used to transfer the program
control unconditionally from one
point to another
its functionality is limited and it is only
recommended as a last resort if structured
solutions are much more complicated

More Related Content

What's hot

If else statement in c++
If else statement in c++If else statement in c++
If else statement in c++
Bishal Sharma
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
rajshreemuthiah
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Forloop
ForloopForloop
Forloop
Dipen Vasoya
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
University of Potsdam
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
Control statements
Control statementsControl statements
Control statements
Kanwalpreet Kaur
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming language
sanjay joshi
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 
10. switch case
10. switch case10. switch case
10. switch case
Way2itech
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 

What's hot (20)

If else statement in c++
If else statement in c++If else statement in c++
If else statement in c++
 
Loops in c
Loops in cLoops in c
Loops in c
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
 
Loops c++
Loops c++Loops c++
Loops c++
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Forloop
ForloopForloop
Forloop
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Control statements
Control statementsControl statements
Control statements
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming language
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
10. switch case
10. switch case10. switch case
10. switch case
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 

Similar to Control statement-Selective

2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
ManojKhadilkar1
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptx
ssuserfb3c3e
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
nmahi96
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
Module 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdfModule 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdf
SudipDebnath20
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
Mehul Desai
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
Unit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment exampleUnit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment example
umaghosal12101974
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
SKUP1
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
LECO9
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
Vikram Nandini
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
ishaparte4
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
SmitaAparadh
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3
Abou Bakr Ashraf
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
CGC Technical campus,Mohali
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 

Similar to Control statement-Selective (20)

2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptx
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Module 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdfModule 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdf
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Unit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment exampleUnit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment example
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

Control statement-Selective

  • 1. Prepared by: Mrs. Nurul Zakiah Binti Zamri Tan CONTROL STATEMENT
  • 2. TYPE OF CONTROL STATEMENT C support 3 kinds of control structure: sequential selective iterative
  • 3. statement that is used to alter the continuous sequential execution of statements sequential no branching, looping or have any decision making in the statement A series of coding. Source code is execute one after and after. CONTROL STATEMENT ?? Use to control the flow of the source code/programming Key to write a structured program where CS can : Reduce complexity Improve clarity. Facilitate debugging and modifying Technique to organize a program
  • 4. Operation is simple to trace ADVATAGES OF CONTROL STATEMENT Structures are easier to define in flowcharts Structure programming increases programmer's productivity
  • 5. CONTROL STATEMENT Simple if statement If else statement If-else if ladder statement Switch case statement go to statement for statement While statement do-while Unconditional Conditional Looping
  • 6. If statement If (test condition) { Statement block; } Next statement; GENERAL FORM #include <stdio.h> #include <conio.h> int main (void) { int num1; int num2; printf (“Please Enter 2 numbers”); scanf(“%d%d”, &num1,&num2); If (num1== num2) { printf(“There are equal”); } getch(); } EXAMPLE To execute one statement or group of statements for particular condition
  • 7. If –else-statement If (test condition) { Statement block-1; } else { Statement block-2 } Next statement; GENERAL FORM #include <stdio.h> void main() { int mark; printf (“Please Enter mark”); scanf( “%d”, &mark); If (mark=>39) { printf(“Pass”); } else { printf(“Fail”); } getch(); } EXAMPLE To execute one group of statements if the test condition is true or other group if the test condition is false
  • 8. If else.. ladder statement If (test condition-1) { Statement block-1; } Else if (test condition-2) { Statement block-2; } … … Else if (test condition-n) { Statement block-n; } Else Default statement; Next statement; GENERAL FORM To take multiple decision. This statement is form by joining if..else statement. If one condition is false, it checks for the next condition and so on. When all the conditions are false, then else block is executed
  • 9. #include<stdio.h> #include<string.h> void main() { int n; printf(" Enter 1 to 3 to select your pet"); scanf("%d",&n); if(n==1) { printf("You pet is a tiger"); } else if(n==2) { printf("You pet is a sugar glider"); } else if(n==3) { printf("You pet is a cow"); } else { printf("No pet selected"); } getch(); } EXAMPLE If else.. ladder statement
  • 10. switch statement switch (expression) { case value1: Statement block-1: break; case value2: Statement block-2: break; … .. . case value-n: statement block-n: break; default: default statement; break; } Next statement GENERAL FORM Alternative to if else if ..ladder statement to execute a block of code based on selection from multiple choices. C switch statement is a multiway decisions that tests whether a variable or expression matches one of a number of constant integer values, and branches accordingly. 'break' is a statement. It is most commonly used with the switch statement. 'break' statement stops the execution within the switch statement and exits from the switch statement.
  • 11. #include <stdio.h> main() { int Grade; choose: printf(“Please insert your grade A, B, C, D, E, or F”); scanf("%d",&Grade); switch( Grade ) { case 'A' : printf( "Excellentn" ); break; case 'B' : printf( "Goodn" ); break; case 'C' : printf( "OKn" ); break; EXAMPLE case 'D' : printf( "Mmmmm....n" ); break; case 'F' : printf( "You must do better than thisn" ); break; default : printf( "What is your grade anyway?n" ); go to choose; break; } getch(); }
  • 12. goto statement goto label: GENERAL FORM Used to transfer the program control unconditionally from one point to another its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated