SlideShare a Scribd company logo
Gagan Deep 
Rozy Computech Services 
3rd Gate, K.U., Kurukshetra-136119 
M- 9416011599 
Email – rozygag@yahoo.com
Nested Loops 
 Loops, like if-else statements, can be nested, one within 
another. 
 The inner and outer loops need not be generated by the 
same type of control structure. 
 It is essential, however, that one loop be completely 
embedded within the other - there can be no overlap. 
 Each loop must be controlled by different index. 
 Moreover, nested control structure can involve both loops 
and if-else statement. 
 Thus, a loop can be nested within an if-else statement, 
and an if-else statement can be nested within a loop. 
 The nested structure may be complex as necessary, as 
determined by the program logic.
Tables of 1-10 Program 1-4 
#include <stdio.h> 
void main() 
{ int i,j; 
for (i=1; i<=10; i++) 
for(j=1; j<=10; j++) 
printf(“%d ”, i*j); 
Prints 1 2 3 ..10 2 4 6 ..20 ………10 20 30 ……..100 
#include <stdio.h> 
void main() 
{ int i=1,J; 
while(i<=10) 
{ for (j=1; j<=10; j++) 
printf(“ %dt”, i*j); 
i++; } } 
#include <stdio.h> 
void main() 
{ int i=1,j=1; 
while(i<=10) 
{ while(j<=10) 
{ printf(“ %d”, i*j); 
j++;} 
i++;} } 
#include <stdio.h> 
void main() 
{ int i,j =1; 
for (i=1; i<=10; i++) 
d0 
{ printf(“%dn ”, i*j); 
j++; } 
while(j<=10) ; }
Program 5-6 
Check Palindrome Number from 
11 to 500 
#include<stdio.h> 
void main() 
{int i, r, T, rn=0; 
for ( i = 11; i<=500; i++) { 
T=i; 
while (T!=0) { 
r=T%10; T=T/10 ; 
rn=rn*10+r; } 
if (rn==i) 
printf(“%d is Palindrome Number”, ); 
else 
printf(“%d is Non-Palindrome Number); 
} } 
Check Palindrome Number from 11 to 
500 
#include<stdio.h> 
void main() 
{int n=11,r, T, rn=0; 
while(n<=500) { 
T=n; 
while (T!=0) { 
r=T%10; T=T/10 ; 
rn=rn*10+r; } 
if (rn==n) 
printf(“%d is Palindrome Number”, ); 
} }
Jumping Statements 
 Jumping statements are also known as Loop Control 
Statements. 
 Jumping statements are of different types 
 break 
 continue 
 goto 
 return 
 exit ()
break Statements 
 break statement simply terminates the loop and takes 
control out of the loop. Here explained break statement for 
for Loop 
for(…………….) 
{ 
.. . . . . . . . 
.. . . . . . . . 
if (condition) 
break; 
.. . . . . . . . 
.. . . . . . . . 
} 
8. Print sum of infinite numbers. 
#include <stdio.h> 
void main () 
{ int a, sum=0; 
for( ; ; ) 
{ scanf(“%d”, &a); 
if (a==-999) 
break; 
sum=sum+a; } 
printf(“The sum is %d”, 
sum); }
break statement for while & do While Loop 
while(……..) 
{ 
. . . . . . . . . 
. . . . . . . . . 
if (condition) 
break; 
. . . . . . . . . 
. . . . . . . . . 
} 
. . . . . . . . . 
. . . . . . . . . 
do 
{ 
. . . . . . . . . 
. . . . . . . . . 
if (condition) 
break; 
. . . . . . . . . 
. . . . . . . . . } 
while (…….); 
. . . . . . . . . 
. . . . . . . . .
Continue Statement 
 Continue is used for skipping a part of loop for some 
condition. 
 Continue causes the remaining code inside a loop block 
to be skipped and causes execution of jump to the top 
of loop block 
for(…………….) 
{ 
.. . . . . . . . 
.. . . . . . . . 
if (condition) 
continue; 
.. . . . . . . . 
.. . . . . . . . 
} 
12 Print 1-10 numbers except 3 and 7 
#include <stdio.h> 
void main () 
{ 
int i; 
for(i=1 ; 1<=10 ; i++) 
{ 
if ((i==3)||(i==7)) 
continue; 
printf(“ %dt”, i); 
} }
continue statement for while & do-while Loops 
while(……..) 
{ 
. . . . . . . . . 
. . . . . . . . . 
if (condition) 
continue; 
. . . . . . . . . 
. . . . . . . . . 
} 
. . . . . . . . . 
. . . . . . . . . 
do 
{ 
. . . . . . . . . 
. . . . . . . . . 
if (condition) 
continue; 
. . . . . . . . . 
. . . . . . . . . } 
while (…….); 
. . . . . . . . . 
. . . . . . . . .
goto statement 
goto label1 
. . . . . . . . . . 
. . . . . . . . . . 
label2: 
. . . . . . . . . . 
. . . . . . . . . . 
label1: 
. . . . . . . . . . 
. . . . . . . . . . 
goto label2 
 The goto statement is used to alter the 
normal sequence of program 
execution by transferring control to 
some other part of the program 
unconditionally/conditionally. 
 In its general form, the goto 
statement is written as 
 goto label; 
 where the label is an identifier that 
is used to label the target statement to 
which the control is transferred. 
label : statement; 
 Each labeled statement within the 
function must have a unique label, 
i.e., no two statement can have the 
same label.
return statement and exit() 
 return is an instruction of the language that returns from a 
function call. 
 exit is a system call (not a language statement) that 
terminates the current process.
Print Prime numbers in between 2-100 Prog. 16 
#include <stdio.h> 
void main () 
{ 
int i, j; 
for(i=2; i<100; i++) 
{ 
for(j=2; j <= (i/j); j++) 
if(!(i%j)) 
break; 
// if factor found, not prime 
if(j > (i/j)) 
printf ("%d is primen", i); 
} 
}
Examples of Pyramid Program 17 
#include <stdio.h> 
void main() 
{ 
int i,j,l; 
printf(“Number of lines: "); 
scanf("%d",&l); 
for(i=1;i<=l;++i) 
{ 
for(j=1;j<=i;++j) 
printf("* "); // printf(“j "); 
printf("n"); 
} 
} 
* 1 
** 12 
*** 123 
**** 1234 
***** 12345
Do Yourself 
 Count even and digits of a number 
 Sum of even and odd digits of a number 
 Check for Armstrong Number 
 Fibonacci Sequence 
 Prime number when divide upto n/2 and sqrt of n
If you have any queries you can 
contact me at : 
rozygag@yahoo.com

More Related Content

What's hot

Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
University of Potsdam
 
Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
Python tuple
Python   tuplePython   tuple
Python tuple
Mohammed Sikander
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
Rabin BK
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
Dr.Subha Krishna
 
Functions in c
Functions in cFunctions in c
Functions in c
sunila tharagaturi
 
C if else
C if elseC if else
C if else
Ritwik Das
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
C function presentation
C function presentationC function presentation
C function presentation
Touhidul Shawan
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
Mohammed Sikander
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++Danial Mirza
 
C functions
C functionsC functions
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 

What's hot (20)

Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
Control structures in c
Control structures in cControl structures in c
Control structures in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Function in c
Function in cFunction in c
Function in c
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
C if else
C if elseC if else
C if else
 
Inline function
Inline functionInline function
Inline function
 
Chap 9(functions)
Chap 9(functions)Chap 9(functions)
Chap 9(functions)
 
C function presentation
C function presentationC function presentation
C function presentation
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++
 
C functions
C functionsC functions
C functions
 
Strings
StringsStrings
Strings
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 

Viewers also liked

Loops
LoopsLoops
Nesting of for loops using C++
Nesting of for loops using C++Nesting of for loops using C++
Nesting of for loops using C++
prashant_sainii
 
Loops
LoopsLoops
For...next loop structure
For...next loop structureFor...next loop structure
For...next loop structureJd Mercado
 
Az ve Öz C++ Muhammet ÇAĞATAY
Az ve Öz C++  Muhammet ÇAĞATAYAz ve Öz C++  Muhammet ÇAĞATAY
Az ve Öz C++ Muhammet ÇAĞATAY
Muhammet ÇAĞATAY
 
6 lanjutan perulangan
6 lanjutan perulangan6 lanjutan perulangan
6 lanjutan perulangan
Simon Patabang
 
Software Project Planning V
Software Project Planning VSoftware Project Planning V
Software Project Planning V
Gagan Deep
 
Software Project Planning III
Software Project Planning IIISoftware Project Planning III
Software Project Planning III
Gagan Deep
 
Software Project Planning IV
Software Project Planning IVSoftware Project Planning IV
Software Project Planning IV
Gagan Deep
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- I
Gagan Deep
 
Perulangan While do, For to do, dan Repeat Until dalam Pascal
Perulangan While do, For to do, dan Repeat Until dalam PascalPerulangan While do, For to do, dan Repeat Until dalam Pascal
Perulangan While do, For to do, dan Repeat Until dalam Pascal
Teknik Informatika UII
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
Gagan Deep
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
Gagan Deep
 
Normalization 1
Normalization 1Normalization 1
Normalization 1
Gagan Deep
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i iGagan Deep
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Gagan Deep
 
SQL – A Tutorial I
SQL – A Tutorial  ISQL – A Tutorial  I
SQL – A Tutorial I
Gagan Deep
 
Information System and MIS
Information System and MISInformation System and MIS
Information System and MIS
Gagan Deep
 
System Analysis & Design - 2
System Analysis & Design - 2System Analysis & Design - 2
System Analysis & Design - 2
Gagan Deep
 
Kumpulan contoh-program-pascal
Kumpulan contoh-program-pascalKumpulan contoh-program-pascal
Kumpulan contoh-program-pascalrey25
 

Viewers also liked (20)

Loops
LoopsLoops
Loops
 
Nesting of for loops using C++
Nesting of for loops using C++Nesting of for loops using C++
Nesting of for loops using C++
 
Loops
LoopsLoops
Loops
 
For...next loop structure
For...next loop structureFor...next loop structure
For...next loop structure
 
Az ve Öz C++ Muhammet ÇAĞATAY
Az ve Öz C++  Muhammet ÇAĞATAYAz ve Öz C++  Muhammet ÇAĞATAY
Az ve Öz C++ Muhammet ÇAĞATAY
 
6 lanjutan perulangan
6 lanjutan perulangan6 lanjutan perulangan
6 lanjutan perulangan
 
Software Project Planning V
Software Project Planning VSoftware Project Planning V
Software Project Planning V
 
Software Project Planning III
Software Project Planning IIISoftware Project Planning III
Software Project Planning III
 
Software Project Planning IV
Software Project Planning IVSoftware Project Planning IV
Software Project Planning IV
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- I
 
Perulangan While do, For to do, dan Repeat Until dalam Pascal
Perulangan While do, For to do, dan Repeat Until dalam PascalPerulangan While do, For to do, dan Repeat Until dalam Pascal
Perulangan While do, For to do, dan Repeat Until dalam Pascal
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
 
Normalization 1
Normalization 1Normalization 1
Normalization 1
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i i
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
SQL – A Tutorial I
SQL – A Tutorial  ISQL – A Tutorial  I
SQL – A Tutorial I
 
Information System and MIS
Information System and MISInformation System and MIS
Information System and MIS
 
System Analysis & Design - 2
System Analysis & Design - 2System Analysis & Design - 2
System Analysis & Design - 2
 
Kumpulan contoh-program-pascal
Kumpulan contoh-program-pascalKumpulan contoh-program-pascal
Kumpulan contoh-program-pascal
 

Similar to C lecture 4 nested loops and jumping statements slideshare

3. control statement
3. control statement3. control statement
3. control statement
Shankar Gangaju
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
Chandrakant Divate
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.com
Green Ecosystem
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
Vikram Nandini
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
Session 3
Session 3Session 3
Loops
LoopsLoops
Loops
Kamran
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
Vikash Dhal
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)jahanullah
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
msharshitha03s
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
Gagan Deep
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptx
DEEPAK948083
 
Decision Making and Looping
Decision Making and LoopingDecision Making and Looping
Decision Making and Looping
Munazza-Mah-Jabeen
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
kapil078
 
What is c
What is cWhat is c
What is c
Nitesh Saitwal
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 

Similar to C lecture 4 nested loops and jumping statements slideshare (20)

3. control statement
3. control statement3. control statement
3. control statement
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.com
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Session 3
Session 3Session 3
Session 3
 
Loops
LoopsLoops
Loops
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptx
 
Decision Making and Looping
Decision Making and LoopingDecision Making and Looping
Decision Making and Looping
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 
What is c
What is cWhat is c
What is c
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 

More from Gagan Deep

Number system
Number systemNumber system
Number system
Gagan Deep
 
Software Project Planning II
Software Project Planning IISoftware Project Planning II
Software Project Planning II
Gagan Deep
 
Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1
Gagan Deep
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
System Analysis & Design - I
System Analysis & Design - ISystem Analysis & Design - I
System Analysis & Design - I
Gagan Deep
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebraGagan Deep
 
Plsql overview
Plsql overviewPlsql overview
Plsql overview
Gagan Deep
 

More from Gagan Deep (7)

Number system
Number systemNumber system
Number system
 
Software Project Planning II
Software Project Planning IISoftware Project Planning II
Software Project Planning II
 
Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
System Analysis & Design - I
System Analysis & Design - ISystem Analysis & Design - I
System Analysis & Design - I
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Plsql overview
Plsql overviewPlsql overview
Plsql overview
 

Recently uploaded

Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 

Recently uploaded (20)

Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 

C lecture 4 nested loops and jumping statements slideshare

  • 1. Gagan Deep Rozy Computech Services 3rd Gate, K.U., Kurukshetra-136119 M- 9416011599 Email – rozygag@yahoo.com
  • 2. Nested Loops  Loops, like if-else statements, can be nested, one within another.  The inner and outer loops need not be generated by the same type of control structure.  It is essential, however, that one loop be completely embedded within the other - there can be no overlap.  Each loop must be controlled by different index.  Moreover, nested control structure can involve both loops and if-else statement.  Thus, a loop can be nested within an if-else statement, and an if-else statement can be nested within a loop.  The nested structure may be complex as necessary, as determined by the program logic.
  • 3. Tables of 1-10 Program 1-4 #include <stdio.h> void main() { int i,j; for (i=1; i<=10; i++) for(j=1; j<=10; j++) printf(“%d ”, i*j); Prints 1 2 3 ..10 2 4 6 ..20 ………10 20 30 ……..100 #include <stdio.h> void main() { int i=1,J; while(i<=10) { for (j=1; j<=10; j++) printf(“ %dt”, i*j); i++; } } #include <stdio.h> void main() { int i=1,j=1; while(i<=10) { while(j<=10) { printf(“ %d”, i*j); j++;} i++;} } #include <stdio.h> void main() { int i,j =1; for (i=1; i<=10; i++) d0 { printf(“%dn ”, i*j); j++; } while(j<=10) ; }
  • 4. Program 5-6 Check Palindrome Number from 11 to 500 #include<stdio.h> void main() {int i, r, T, rn=0; for ( i = 11; i<=500; i++) { T=i; while (T!=0) { r=T%10; T=T/10 ; rn=rn*10+r; } if (rn==i) printf(“%d is Palindrome Number”, ); else printf(“%d is Non-Palindrome Number); } } Check Palindrome Number from 11 to 500 #include<stdio.h> void main() {int n=11,r, T, rn=0; while(n<=500) { T=n; while (T!=0) { r=T%10; T=T/10 ; rn=rn*10+r; } if (rn==n) printf(“%d is Palindrome Number”, ); } }
  • 5. Jumping Statements  Jumping statements are also known as Loop Control Statements.  Jumping statements are of different types  break  continue  goto  return  exit ()
  • 6. break Statements  break statement simply terminates the loop and takes control out of the loop. Here explained break statement for for Loop for(…………….) { .. . . . . . . . .. . . . . . . . if (condition) break; .. . . . . . . . .. . . . . . . . } 8. Print sum of infinite numbers. #include <stdio.h> void main () { int a, sum=0; for( ; ; ) { scanf(“%d”, &a); if (a==-999) break; sum=sum+a; } printf(“The sum is %d”, sum); }
  • 7. break statement for while & do While Loop while(……..) { . . . . . . . . . . . . . . . . . . if (condition) break; . . . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . . . . do { . . . . . . . . . . . . . . . . . . if (condition) break; . . . . . . . . . . . . . . . . . . } while (…….); . . . . . . . . . . . . . . . . . .
  • 8. Continue Statement  Continue is used for skipping a part of loop for some condition.  Continue causes the remaining code inside a loop block to be skipped and causes execution of jump to the top of loop block for(…………….) { .. . . . . . . . .. . . . . . . . if (condition) continue; .. . . . . . . . .. . . . . . . . } 12 Print 1-10 numbers except 3 and 7 #include <stdio.h> void main () { int i; for(i=1 ; 1<=10 ; i++) { if ((i==3)||(i==7)) continue; printf(“ %dt”, i); } }
  • 9. continue statement for while & do-while Loops while(……..) { . . . . . . . . . . . . . . . . . . if (condition) continue; . . . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . . . . do { . . . . . . . . . . . . . . . . . . if (condition) continue; . . . . . . . . . . . . . . . . . . } while (…….); . . . . . . . . . . . . . . . . . .
  • 10. goto statement goto label1 . . . . . . . . . . . . . . . . . . . . label2: . . . . . . . . . . . . . . . . . . . . label1: . . . . . . . . . . . . . . . . . . . . goto label2  The goto statement is used to alter the normal sequence of program execution by transferring control to some other part of the program unconditionally/conditionally.  In its general form, the goto statement is written as  goto label;  where the label is an identifier that is used to label the target statement to which the control is transferred. label : statement;  Each labeled statement within the function must have a unique label, i.e., no two statement can have the same label.
  • 11. return statement and exit()  return is an instruction of the language that returns from a function call.  exit is a system call (not a language statement) that terminates the current process.
  • 12. Print Prime numbers in between 2-100 Prog. 16 #include <stdio.h> void main () { int i, j; for(i=2; i<100; i++) { for(j=2; j <= (i/j); j++) if(!(i%j)) break; // if factor found, not prime if(j > (i/j)) printf ("%d is primen", i); } }
  • 13. Examples of Pyramid Program 17 #include <stdio.h> void main() { int i,j,l; printf(“Number of lines: "); scanf("%d",&l); for(i=1;i<=l;++i) { for(j=1;j<=i;++j) printf("* "); // printf(“j "); printf("n"); } } * 1 ** 12 *** 123 **** 1234 ***** 12345
  • 14. Do Yourself  Count even and digits of a number  Sum of even and odd digits of a number  Check for Armstrong Number  Fibonacci Sequence  Prime number when divide upto n/2 and sqrt of n
  • 15. If you have any queries you can contact me at : rozygag@yahoo.com