SlideShare una empresa de 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

Más contenido relacionado

Similar a C-PROGRAMING FOR LOOP PPT

Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
bsdeol28
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
jewelyngrace
 

Similar 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

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

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