Pyramid Star Pattern....

 





Program in C to print star pyramid pattern .

 
#include<stdio.h>

#include<conio.h>

int main()

{

int n, s, i, j;

printf("Enter number of rows: ");

scanf("%d",&n);

for(i = 1; i <= n; i++)

{

//for loop for displaying space

for(s = i; s < n; s++)

{

printf(" ");

}

//for loop to display star equal to row number

for(j = 1; j <= (2 * i - 1); j++)

{

printf("*");

}

// ending line after each row

printf("\n");

}

}


Output:



Popular posts from this blog

When a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword - Hacker Rank Solution.

You are given a date. You just need to write the method getDay which returns the day on that date - Hacker Rank Solution.

Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solution is provided for you in the editor; you must format and print the input to complete the solution.