;

C Program to Print Two Inverted Right Angle Triangle in opposite Direction using an Asterisk(*)


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print two inverted right-angle triangles in opposite directions using an asterisk(*).

Here is the code of the program to print two inverted right-angle triangles in opposite directions using an asterisk(*).

Code - C Program to Print Two Inverted Right Angle Triangle in opposite Direction using an Asterisk(*)
/*C Program to Print Two Inverted Right Angle Triangle in opposite Direction using an Asterisk(*):
    **********
    ****  ****
    ***    ***
    **      **
    *        *
*/

#include<stdio.h>

#define MAX	5

int main()
{
	int i,j;
	int space=0;
	/*run loop (parent loop) till number of rows*/
	for(i=MAX;i>0;i--)
	{
		/*print first set of stars*/
		for(j=0;j< i;j++)
		{
			printf("*");
		}
		for(j=0;j< space;j++)
		{
			printf(" ");
		}
		/*print second set of stars*/
		for(j=0;j< i;j++)
		{
			printf("*");
		}
		
		printf("\n");
		space+=2;
	}
    return 0;
}
Output

**********
****   ****
***      ***
**         **
*            *

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


Related Posts



Comments

Recent Posts
Tags