In this article I would like to share with you a sample program that will display a pyramid of numbers image using C as my programming language it uses three for loop statements in order to achieve the pyramid image. I am using CodeBlocks as my text editor and Dev C++ as my C and C++ compiler.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
/* Author: Mr. Jake R. Pomperada,MAED-IT */
/* Date : February 15, 2017 */
/* Language : C */
#include <stdio.h>
int main()
{
int a=0,b=0,c=0;
printf("\n\n");
printf("\n\tPYRAMID OF NUMBERS IN C");
printf("\n\n");
for (a=1; a<=9; a++) {
for (c=a; c<=9; c++) {
printf(" ");
}
for (b=1; b<=a; b++) {
printf(" %2d ",b);
}
printf("\n");
}
printf("\n\n");
printf("\n\t END OF PROGRAM");
printf("\n\n");
}
No comments:
Post a Comment