C : Program for printing asterisk in right angle triangle shape

--

Program :

//c program for printing asterisk in right angle triangle shape

#include<stdio.h>

int main()
{
int rows;

printf("Enter the number of rows :");
scanf("%d", &rows);

for(int i=1; i<=rows; i++)
{
for(int j=1; j<=rows; j++)
{
if(j==1 || i==j || i==rows)
{
printf("* ");
}
else
{
printf(" ");
}
}
printf("\n");
}

return 0;
}

Output :

--

--

Programmer Portfolio
Programmer Portfolio

Written by Programmer Portfolio

Code enthusiast. Learning, practicing, and sharing my journey through various programming languages, one code at a time. 🚀💻

No responses yet