SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Semelhante a C-PROGRAMING FOR LOOP PPT

Semelhante a 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
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
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
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
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
 
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
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
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...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.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..
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
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...
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
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"
 
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
 
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"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . 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...
 
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...
 

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