In the previous post we learn about Program for palindrome number in C and Sum of digits in C and in this post we will learn how to create pyramid, half of pyramid and patterns using *
We can create pyramid, half pyramid and patterns by using loops if, if else.
you need to have the basic knowledge of loops if...else ,while, do while, continue and break.
We can create pyramid, half pyramid and patterns by using loops if, if else.
you need to have the basic knowledge of loops if...else ,while, do while, continue and break.
Program to print patterns and pyramids and half pyramids :
1.Program to print half pyramid print using * :
#include <stdio.h> #include <conio.h> int main() { int i, j, r; for(i=1; i<=5; i++) { for(j=1; j<=i; j++) { printf("* "); } printf("\n"); } return 0; }
Output:
*
**
***
****
*****
0 comments:
Post a Comment