C Programming language

adplus-dvertising
C Program example: Reverse star triangle
Previous Home Next

In this example we are going to print reverse star triangle using C. In this example we are print *******..n in first line,******..n-1 in second line,*******..n-2 in third line so on.

/* Rreverse of triangle  */

/*      * * * * *        */
/*      * * * *          */
/*      * * *            */
/*      * *              */
/*      *                */


#include<stdio.h>             
#include<conio.h>             
void main()                  
{                            
	int i,j,n;                   
	clrscr();
	printf("Enter a number\t:");
	scanf("%d",&n);
	for(i=n;i>=1;i--)
	{
		for(j=1;j<=i;j++)
			printf("*");
		printf("\n");
	}
	getch();
}
Output:
      * * * * *        
      * * * *          
      * * *            
      * *              
      *                
Previous Home Next