SlideShare une entreprise Scribd logo
1  sur  12
C-programming presentatio
For Loop In - C
 The for loop in c language is also used t
iterate the statement or a part of the progra
several times like while and do –while loo
 But, we can initialize and increment or
decrement the variable also at the time of
checking the condition in for loop.
 Unlike do while loop the condition or
expression in for loop is given before the
statement, so it may execute the statement
more times.
Whenusefor loopin C
 For loop is better if number of iteration is
known by the programmer
Syntax of for loop in C
 The syntax of for loop in c language
is given below
For (initialization; condition; inner/decr ){
//code to be executed
}
How for loop works
 Initialization
 Condition checking
 Incremented of decremented,
and condition checking
STA
RT
INITIALIZATI
ON
CON
DIT
-
ON
UPDTE
COUNTER
CODE INSKLE
LOOP
STO
P
FALSE
TRUE
FLOW CHART
Enter a
number :2
2,4,6,8,10,12,1
4,18,20
#include <stdio.h>
Int main()
{
Int i=1,number=0;
Printf(“enter a number:”);
Scanf(“%dn”,& number);
For(i=1;i<=10;i++)
{
Printf(“%dn”,(number*i))
}
Return0;
}
code output
Print
table for
the given
number
using C
for loop
 If you don’t initialize any variable, check condition and
increment or decrement variable in for loop, it is known as
infinitive for loop.
 In other words, if you place 2 semicolons in for loop, it is
known as infinitive for loop.
Infinitive for loop in C
For (;;){
Printf(“infinitive for loop example by java point”);
}
• A for loop inside
another for loop
is called nested
for loop.
• Outer loop
represent row
and inner loop
will represent
column
• This loop runs as
long as the
condition in the
parenthesis is true
• ANSI C allows up
to 15 levels of
nesting
• The inner loop
runs as many times
as there is the limit
of the condition of
the external loop.
NESTED FOR LOOP
NESTED FOR LOOP SYNTAX....
For (initiation; condition;
increment/decrement)
{
For (initialization; condition; updation)
{
Body of the loop;
}
}
CON
DITI
ON 1
CON
DITI
ON 2
STATEMENTS
END FOR
END FOR
INCREM-
ENT/DECR
EMENT
INCREM-
ENT/DECR
EMENT
INITIALIZATION
FALSE
FALSE
TRUE
TRUE
NESTED FOR LOOP FLOW CHART....
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("* ");
}
printf("n");
}
return 0;
}
Output...........
Program...........
NESTED FOR LOOP EXAMPLE - 1
#include <stdio.h>
int main()
{
int n,m=1;
printf("Enter the number
of rows");
scanf("%d",&n);
for(int i=n;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
printf("n");
}
return 0;
}
Program............. Output.........
NESTED FOR LOOP EXAMPLE - 2
END OF THE PRESENTATION

Contenu connexe

Similaire à C-PROGRAMING FOR LOOP PPT

Similaire à C-PROGRAMING FOR LOOP PPT (20)

Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
LOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptxLOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptx
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops in c
Loops in cLoops in c
Loops in c
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
 
Loop structures
Loop structuresLoop structures
Loop structures
 
loops in C ppt.pdf
loops in C ppt.pdfloops in C ppt.pdf
loops in C ppt.pdf
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Loop-1.pptx
Loop-1.pptxLoop-1.pptx
Loop-1.pptx
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Chp4_C++_Control Structures-Part2_Iteration.pptx
Chp4_C++_Control Structures-Part2_Iteration.pptxChp4_C++_Control Structures-Part2_Iteration.pptx
Chp4_C++_Control Structures-Part2_Iteration.pptx
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Programming Fundamentals lecture 8
Programming Fundamentals lecture 8Programming Fundamentals lecture 8
Programming Fundamentals lecture 8
 

Dernier

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
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
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
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
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Dernier (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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...
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
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
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

C-PROGRAMING FOR LOOP PPT

  • 1. C-programming presentatio For Loop In - C  The for loop in c language is also used t iterate the statement or a part of the progra several times like while and do –while loo  But, we can initialize and increment or decrement the variable also at the time of checking the condition in for loop.  Unlike do while loop the condition or expression in for loop is given before the statement, so it may execute the statement more times.
  • 2. Whenusefor loopin C  For loop is better if number of iteration is known by the programmer Syntax of for loop in C  The syntax of for loop in c language is given below For (initialization; condition; inner/decr ){ //code to be executed }
  • 3. How for loop works  Initialization  Condition checking  Incremented of decremented, and condition checking
  • 5. Enter a number :2 2,4,6,8,10,12,1 4,18,20 #include <stdio.h> Int main() { Int i=1,number=0; Printf(“enter a number:”); Scanf(“%dn”,& number); For(i=1;i<=10;i++) { Printf(“%dn”,(number*i)) } Return0; } code output Print table for the given number using C for loop
  • 6.  If you don’t initialize any variable, check condition and increment or decrement variable in for loop, it is known as infinitive for loop.  In other words, if you place 2 semicolons in for loop, it is known as infinitive for loop. Infinitive for loop in C For (;;){ Printf(“infinitive for loop example by java point”); }
  • 7. • A for loop inside another for loop is called nested for loop. • Outer loop represent row and inner loop will represent column • This loop runs as long as the condition in the parenthesis is true • ANSI C allows up to 15 levels of nesting • The inner loop runs as many times as there is the limit of the condition of the external loop. NESTED FOR LOOP
  • 8. NESTED FOR LOOP SYNTAX.... For (initiation; condition; increment/decrement) { For (initialization; condition; updation) { Body of the loop; } }
  • 9. CON DITI ON 1 CON DITI ON 2 STATEMENTS END FOR END FOR INCREM- ENT/DECR EMENT INCREM- ENT/DECR EMENT INITIALIZATION FALSE FALSE TRUE TRUE NESTED FOR LOOP FLOW CHART....
  • 10. #include <stdio.h> int main() { int n; printf("Enter the number of rows"); scanf("%d",&n); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { printf("* "); } printf("n"); } return 0; } Output........... Program........... NESTED FOR LOOP EXAMPLE - 1
  • 11. #include <stdio.h> int main() { int n,m=1; printf("Enter the number of rows"); scanf("%d",&n); for(int i=n;i>=1;i--) { for(int j=1;j<=i;j++) { printf("*"); } printf("n"); } return 0; } Program............. Output......... NESTED FOR LOOP EXAMPLE - 2
  • 12. END OF THE PRESENTATION