These program prints various different patterns of numbers and stars.
These codes illustrate how to create various patterns using c
programming. Most of these c programs involve usage of nested loops and
space. A pattern of numbers, star or characters is a way of arranging
these in some logical manner or they may form a sequence. Some of these
patterns are triangles which have special importance in mathematics.
Some patterns are symmetrical while other are not. Please see the
complete page and look at comments for many different patterns.
* *** ***** ******* *********
We have shown five rows above, in the program you will be asked to enter the numbers of rows you want to print in the pyramid of stars.
#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; }
No comments:
Post a Comment