Program Description:
In this program We are going to print an inverted right angled triangle by the using the concepts of loop. At first we will ask the user that how many rows he want to print. We will store the number inputted by user in an integer variable. First for loop is used to determine the line number and the second for loop is used to determine the number of * in the particular row. As we need to to change the line after printing adequate number of * we use the line printf("\n"); .
Source Code:
#include<stdio.h>
int main()
{
int n,i,j;
printf("Enter the no of rows:");
scanf("%d",&n);
for(i=n;i>0;i--)
{
for(j=i;j>0;j--)
printf("*");
printf("\n");
}
}
0 Comments