Nested loop.

 nested loop

loop within a loop.

use of nested loop


#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<=n; j++){
printf("*");
}
printf("\n");
}
return 0;
}

output :

enter the number of rows :9
*********
*********
*********
*********
*********
*********
*********
*********
*********

--------------------------------
Process exited after 4.613 seconds with return value 0
Press any key to continue . .


Comments

Popular posts from this blog

Write a program to check if a number is prime or not.

Write a program to print the grades to a student.

write a program (keep taking numbers as input from user until user enters an Odd number)