SlideShare a Scribd company logo
P.Suman
Dept.of Computer Science
Avanthi Degree & P.G College
C programming language, there are circumstances where
you want to do the same thing many times
For example you want to print the same words ten
times.
You could type ten printf function, but it is easier to use
a loop. The only thing you have to do is to setup a loop
that execute the same printf function ten times
A loop is defined as a block of statements, which are
repeatedly executed for a certain number of times
Looping statements are used for running a set of
statements for any number of times
Looping statements are also called as iterative
statements
In C Programming there are mainly two types of loops
Note
C language Looping and conditional statement
Unbounded looping statements are used when we don’t know
how many times the set of statements has to be repeat
Unbounded looping statements can either be a Pre – Test
Loop or be a Post – Test Loop
In Pre – Test Loop, condition is checked before the
beginning of each iteration. If condition is TRUE
repetition is performed, if it is FALSE repetition is not
performed
Pre – Test loop is implemented using ‘while’ statement
In Post – Test Loop, first the block of statements to be
repeat is executed then condition will be tested
That means in Post – Test Loop, condition is checked
after executing the repeating statements, if the condition
is TRUE it repeat the statements again, if it is FALSE
repetition is not performed
Post – Test loop is implemented using ‘do - while’ statement
counter initialization;
while(condition)
{
block of statements;
…..
counter modification;
…..
}
Syntax
#include<stdio.h>
void main()
{
int i=1;
while(i <= 10)
{
printf(“MRITn”);
i++;
}
printf(“END”);
}
int i = 1
i<=10
printf….MRIT
i++
printf….END
Ad

More Related Content

Similar to C language Looping and conditional statement (20)

C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Flow control in c++
Flow control in c++Flow control in c++
Flow control in c++
Subhasis Nayak
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++
guestfb6ada
 
Workbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdfWorkbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdf
DrDineshenScientist
 
cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
RAJCHATTERJEE24
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
LOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptxLOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptx
AFANJIPHILL
 
Loop-1.pptx
Loop-1.pptxLoop-1.pptx
Loop-1.pptx
MuhammadArsalan896347
 
DECISION MAKING.pptx
DECISION MAKING.pptxDECISION MAKING.pptx
DECISION MAKING.pptx
Ayshwarya Baburam
 
C PROGRAMMING. Pptx new required for anyone.
C PROGRAMMING. Pptx new required for anyone.C PROGRAMMING. Pptx new required for anyone.
C PROGRAMMING. Pptx new required for anyone.
makingupmind
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loops
saifullahbhatti99
 
M C6java6
M C6java6M C6java6
M C6java6
mbruggen
 
Chapter 4 flow control structures and arrays
Chapter 4 flow control structures and arraysChapter 4 flow control structures and arrays
Chapter 4 flow control structures and arrays
sshhzap
 
Loops In C++
Loops In C++Loops In C++
Loops In C++
Banasthali Vidyapith
 
lecture-06 Lopikjjiu8iuuiujijijijioop.pptx
lecture-06 Lopikjjiu8iuuiujijijijioop.pptxlecture-06 Lopikjjiu8iuuiujijijijioop.pptx
lecture-06 Lopikjjiu8iuuiujijijijioop.pptx
kingofdeath1380
 
Introduction to loops cpu
Introduction to loops  cpuIntroduction to loops  cpu
Introduction to loops cpu
Harsh Gupta
 
Loop structures
Loop structuresLoop structures
Loop structures
tazeem sana
 
Loops in C.pptx
Loops in C.pptxLoops in C.pptx
Loops in C.pptx
nagalakshmig4
 
etlplooping-170320213203.pptx
etlplooping-170320213203.pptxetlplooping-170320213203.pptx
etlplooping-170320213203.pptx
ffyuyufyfufufufu
 
Eo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5eEo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5e
Gina Bullock
 

More from BalaKrishnan466 (15)

Switch and control statement for c language
Switch and control statement for c languageSwitch and control statement for c language
Switch and control statement for c language
BalaKrishnan466
 
c-Looping-Statements-P-Suman statement for c
c-Looping-Statements-P-Suman statement for cc-Looping-Statements-P-Suman statement for c
c-Looping-Statements-P-Suman statement for c
BalaKrishnan466
 
Switch and control looping statement for C
Switch and control looping statement for CSwitch and control looping statement for C
Switch and control looping statement for C
BalaKrishnan466
 
Switch and looping statement for c language
Switch and looping statement for c languageSwitch and looping statement for c language
Switch and looping statement for c language
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Decision making in C(2020-2021) statements
Decision making in C(2020-2021) statementsDecision making in C(2020-2021) statements
Decision making in C(2020-2021) statements
BalaKrishnan466
 
C array and Initialisation and declaration
C array and Initialisation and declarationC array and Initialisation and declaration
C array and Initialisation and declaration
BalaKrishnan466
 
Basic operators and it's types in c languages
Basic operators and it's types in c languagesBasic operators and it's types in c languages
Basic operators and it's types in c languages
BalaKrishnan466
 
Queues operation using data structure in c
Queues operation using data structure in cQueues operation using data structure in c
Queues operation using data structure in c
BalaKrishnan466
 
Stack operation in data structure in c language
Stack operation in data structure in c languageStack operation in data structure in c language
Stack operation in data structure in c language
BalaKrishnan466
 
Flow chart and algorithm working progress
Flow chart and algorithm working progressFlow chart and algorithm working progress
Flow chart and algorithm working progress
BalaKrishnan466
 
Algorithms and Flowchart usages in C laguage
Algorithms and Flowchart usages in C laguageAlgorithms and Flowchart usages in C laguage
Algorithms and Flowchart usages in C laguage
BalaKrishnan466
 
Data types and it's usage in c languages
Data types and it's usage in c languagesData types and it's usage in c languages
Data types and it's usage in c languages
BalaKrishnan466
 
Switch and control statement for c language
Switch and control statement for c languageSwitch and control statement for c language
Switch and control statement for c language
BalaKrishnan466
 
c-Looping-Statements-P-Suman statement for c
c-Looping-Statements-P-Suman statement for cc-Looping-Statements-P-Suman statement for c
c-Looping-Statements-P-Suman statement for c
BalaKrishnan466
 
Switch and control looping statement for C
Switch and control looping statement for CSwitch and control looping statement for C
Switch and control looping statement for C
BalaKrishnan466
 
Switch and looping statement for c language
Switch and looping statement for c languageSwitch and looping statement for c language
Switch and looping statement for c language
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Control structure and Looping statements
Control structure and Looping statementsControl structure and Looping statements
Control structure and Looping statements
BalaKrishnan466
 
Decision making in C(2020-2021) statements
Decision making in C(2020-2021) statementsDecision making in C(2020-2021) statements
Decision making in C(2020-2021) statements
BalaKrishnan466
 
C array and Initialisation and declaration
C array and Initialisation and declarationC array and Initialisation and declaration
C array and Initialisation and declaration
BalaKrishnan466
 
Basic operators and it's types in c languages
Basic operators and it's types in c languagesBasic operators and it's types in c languages
Basic operators and it's types in c languages
BalaKrishnan466
 
Queues operation using data structure in c
Queues operation using data structure in cQueues operation using data structure in c
Queues operation using data structure in c
BalaKrishnan466
 
Stack operation in data structure in c language
Stack operation in data structure in c languageStack operation in data structure in c language
Stack operation in data structure in c language
BalaKrishnan466
 
Flow chart and algorithm working progress
Flow chart and algorithm working progressFlow chart and algorithm working progress
Flow chart and algorithm working progress
BalaKrishnan466
 
Algorithms and Flowchart usages in C laguage
Algorithms and Flowchart usages in C laguageAlgorithms and Flowchart usages in C laguage
Algorithms and Flowchart usages in C laguage
BalaKrishnan466
 
Data types and it's usage in c languages
Data types and it's usage in c languagesData types and it's usage in c languages
Data types and it's usage in c languages
BalaKrishnan466
 
Ad

Recently uploaded (20)

TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Ad

C language Looping and conditional statement

  • 2. C programming language, there are circumstances where you want to do the same thing many times For example you want to print the same words ten times. You could type ten printf function, but it is easier to use a loop. The only thing you have to do is to setup a loop that execute the same printf function ten times
  • 3. A loop is defined as a block of statements, which are repeatedly executed for a certain number of times Looping statements are used for running a set of statements for any number of times Looping statements are also called as iterative statements
  • 4. In C Programming there are mainly two types of loops Note
  • 6. Unbounded looping statements are used when we don’t know how many times the set of statements has to be repeat Unbounded looping statements can either be a Pre – Test Loop or be a Post – Test Loop In Pre – Test Loop, condition is checked before the beginning of each iteration. If condition is TRUE repetition is performed, if it is FALSE repetition is not performed
  • 7. Pre – Test loop is implemented using ‘while’ statement In Post – Test Loop, first the block of statements to be repeat is executed then condition will be tested That means in Post – Test Loop, condition is checked after executing the repeating statements, if the condition is TRUE it repeat the statements again, if it is FALSE repetition is not performed Post – Test loop is implemented using ‘do - while’ statement
  • 8. counter initialization; while(condition) { block of statements; ….. counter modification; ….. } Syntax
  • 9. #include<stdio.h> void main() { int i=1; while(i <= 10) { printf(“MRITn”); i++; } printf(“END”); } int i = 1 i<=10 printf….MRIT i++ printf….END
  翻译: