0% found this document useful (0 votes)
7 views

Patterns

The document contains two C code programs that print pyramid patterns of stars. The first program allows the user to input the number of rows, then prints that number of rows with descending numbers of spaces before each row of stars, where the number of stars is 2*row-1. The second program also takes a user input for the number of rows, but each row contains the row number of stars with no spaces.

Uploaded by

Manoj Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Patterns

The document contains two C code programs that print pyramid patterns of stars. The first program allows the user to input the number of rows, then prints that number of rows with descending numbers of spaces before each row of stars, where the number of stars is 2*row-1. The second program also takes a user input for the number of rows, but each row contains the row number of stars with no spaces.

Uploaded by

Manoj Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Patterns * ** *** **** *****

#include<stdio.h> main() { int row, c, n, temp; printf("Enter the number of rows in pyramid of stars you wish to see "); scanf("%d",&n); temp = n; for ( row = 1 ; row <= n ; row++ ) { for ( c = 1 ; c < temp ; c++ ) printf(" "); temp--; for ( c = 1 ; c <= 2*row - 1 ; c++ ) printf("*"); printf("\n"); } return 0; }

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


#include<stdio.h> main() { int n, c, k; printf("Enter number of rows\n"); scanf("%d",&n); for ( c = 1 ; c <= n ; c++ ) { for( k = 1 ; k <= c ; k++ ) printf("*"); printf("\n"); } return 0; }

You might also like