Program Description:


This is the program in which we are going to print a pattern with '*' using loops. We are going to print a shape similar to right angled triangle. This is a very interesting code and it will help you to clear the concept of for loop very easily. We will use two for loops to print the pattern. The algorithm is such that the number of  * is the line number. For Example, in the 1st line there is one *, in the second there are two * and so on. The first loop is used to determine the line and the second loop prints the number of stars according to the line number. The line printf("\n"); is used to change the line. This is the first program of pattern series which you must do, irrespective of for what you are doing C programming.
                             

Source code:

#include<stdio.h>
int main()
{
int n,i,j;
printf("Enter the no of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
printf("*");
printf("\n");
}
}


Output:


If you have any queries regarding the program feel free to contact us :-)