\(\begin{array}{c c c c c} & & * & & \\ & * & * & *& \\ * &* & * &* & * \end{array}\)
Write a program that reads a number and displays the above pattern.
Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
int main()
{
int N, i, j;
do{
printf("Enter N: ");
scanf("%d",&N);
}while(N<=0);
for(i=0; i< N; i++)
{
for(j=N; j>=i; j--)
printf(" ");
for(j=0; j <=2*i; j++)
printf("*");
printf("\n");
}
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Simulating a boarding desk