Saturday, 8 May 2021

Nested loops in C with example program

A loop withing another loop is called nested loop. Consider a loop where the outer loop run 'n' time and consists of another loop inside it. The inner loop runs 'm' times. Then the total number of times the inner loop runs during program execution is m*n times.


Example: Write a C program to print the following pattern

*

**

***

****

*****


void main()
{
    int i, j;
    for(i=0;i<=5;i++)
     {
        printf(“\n”);
        
        for(j=1;j<=i;j++)
         {
               printf(“*”);
         }
     }
getch();
}


0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top