/************************************************** * C Program to print Half Pyramid pattern using * **************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");for(inti=1;i<=n;i++){for(intj=1;j<=i;j++){printf("*");}printf("\n");}return0;}
/******************************************************** * C Program to print Half Pyramid pattern using numbers ********************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");for(inti=1;i<=n;i++){for(intj=1;j<=i;j++){printf("%-5d ",j);}printf("\n");}return0;}
/********************************************************** * C Program to print Half Pyramid pattern using alphabets **********************************************************/#include<stdio.h> // include stdio.hintmain(){intn,ch='A';printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=1;i<=n;i++){// loop to print alphabetsfor(intj=1;j<=i;j++){printf(" %c",ch);}ch++;printf("\n");}return0;}
/***************************************************** * C Program to print inverted right triangle pattern******************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=n;i>=1;i--){// loop to print *for(intj=i;j>=1;j--){printf("* ");}printf("\n");}return0;}
/******************************************* * C Program to print full pyramid using * ********************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=1;i<=n;i++){// loop to print leading spaces in each linefor(intspace=0;space<=n-i;space++){printf(" ");}// loop to print *for(intj=1;j<=i*2-1;j++){printf(" * ");}printf("\n");}return0;}
/*************************************************** * C Program to print full inverted pyramid using * ****************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=n;i>=1;i--){// loop to print leading spaces in each linefor(intspace=n-i;space>=1;space--){printf(" ");}// loop to print *for(intj=i*2-1;j>=1;j--){printf(" * ");}printf("\n");}return0;}
/********************************************************** * C Program to print hollow right angled triangle using ************************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for number of linesfor(inti=1;i<=n;i++){for(intj=1;j<=i;j++){// print * only on the first line, last column of every line and on the last lineif(j==1||j==i||i==n){printf("* ");}else{printf(" ");}}printf("\n");}return0;}
/******************************************************************* * C Program to print inverted hollow right angled triangle using *********************************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for number of linesfor(inti=n;i>=1;i--){for(intj=i;j>=1;j--){// print * only on the first line, last line and last column of every line and on the if(j==1||j==i||i==n){printf("* ");}else{printf(" ");}}printf("\n");}return0;}
/************************************************* * C Program to print full hollow pyramid using * *************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=1;i<=n;i++){// loop to print leading spaces in each linefor(intspace=0;space<=n-i;space++){printf(" ");}// loop to print *for(intj=1;j<=i*2-1;j++){if(j==1||(j==i*2-1)||i==n){printf(" * ");}else{printf(" ");}}printf("\n");}return0;}
/********************************************************** * C Program to print full inverted hollow pyramid using * **********************************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop for line number of linesfor(inti=n;i>=1;i--){// loop to print leading spaces in each linefor(intspace=n-i;space>=1;space--){printf(" ");}// loop to print *for(intj=i*2-1;j>=1;j--){if(j==1||(j==i*2-1)||i==n){printf(" * ");}else{printf(" ");}}printf("\n");}return0;}
/********************************************* * C Program to print Diamond pattern using * **********************************************/#include<stdio.h> // include stdio.hintmain(){intn;printf("Enter number of lines: ");scanf("%d",&n);printf("\n");// loop to print upper pyramidfor(inti=1;i<=n;i++){// loop to print leading spaces in each linefor(intspace=0;space<=n-i;space++){printf(" ");}// loop to print *for(intj=1;j<=i*2-1;j++){printf(" * ");}printf("\n");}// loop to print lower pyramid for(inti=n+1;i>=1;i--){// loop to print leading spaces in each linefor(intspace=n-i;space>=0;space--){printf(" ");}// loop to print *for(intj=i*2-1;j>=1;j--){printf(" * ");}printf("\n");}return0;}
Load Comments