C Nested for Loop
You are Here:
C Nested for Loop(s)
We can nest for loops to gain more advantage in some situations. The nesting level is not restricted at all. In the body of a for loop, any number of sub for loop(s) may exist.
Nesting for loop(s)
In the following example program, we will nest loop(s) one within another.
Source Code
C Compiler
#include <stdio.h>
int main()
{
int i, j;
for(i=0; i<2; i++){
printf("Outer for Loop i = %d \n", i);
for(j=0; j<2; j++){
printf(" Inner for Loop j = %d \n", j);
}
}
return 0;
}
Output
Outer for Loop i = 0
Inner for Loop j = 0
Inner for Loop j = 1
Outer for Loop i = 1
Inner for Loop j = 0
Inner for Loop j = 1
Congratulation! you have learned everything about Nested for
loop in C Programming.
Reminder
Hi Developers, we almost covered 98% of String functions and Interview Question on C with examples for quick and easy learning.
We are working to cover every Single Concept in C.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.