Monday, September 14, 2020

Write a Program to print pyramid using # in C.

 Print pyramid using # in C.

 EXAMPLE :-

 
/* This is Pattern program using # in C */

#include <stdio.h>
/* Main function starts from here*/
int main()
{
int i, j, rows;

/* This statement will numer of rows message */
printf("Enter number of rows: ");
scanf("%d",&rows);

/* using for loop*/
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
printf("# ");
}
printf("\n");
}
return 0;
}
 

 

OUTPUT

 
Enter number of rows: 5

#
# #
# # #
# # # #
# # # # # 
 

 

 

No comments:

Post a Comment

Please do not any spam link in Comment Box