Question :

Explain Nested Loops in C Language with example.

Subject

Programming in C

Standard

Computer Science Engineering

Views

1971

Asked By

Rajiv Sharma

Deepak
Answer / Solution

C supports nesting of loops in C. Nesting of loops is the feature in C that allows the looping of statements inside another loop. Let's observe an example of nesting loops in C.

Any number of loops can be defined inside another loop, i.e., there is no restriction for defining any number of loops. The nesting level can be defined at n times. You can define any type of loop inside another loop; for example, you can define 'while' loop inside a 'for' loop.

  1. #include <stdio.h>  
  2. int main()  
  3. {  
  4.    int n;// variable declaration  
  5.    printf("Enter the value of n :");  
  6.    // Displaying the n tables.  
  7.    for(int i=1;i<=n;i++)  // outer loop  
  8.    {  
  9.        for(int j=1;j<=10;j++)  // inner loop  
  10.        {  
  11.            printf("%d\t",(i*j)); // printing the value.  
  12.        }  
  13.        printf("\n");  
  14.    }  

Top Trending Questions


Recent Question Update

Advantages Of NCERT, CBSE & State Boards Solutions For All Subjects

  • All the NCERT Solutions have been prepared by academic experts having 10+ years of teaching experience.
  • They have prepared all the solutions in simple and easy language so that each and every student can understand the concepts easily.
  • All the solutions have been explained step to step-wise in details with better explanations.
  • Students can also use these question and answers for your assignments and in homework help.
  • All the solutions have been explained in detail and the answers have been compiled in a step-wise manner.
  • All the questions and answers are commonly prepared according to the Latest Syllabus of Board Education and Guidelines.
  • Students can know about the various types of questions asked in the exams with the help of these solutions.

Top Course Categories