C Program to print decreasing rectangular pyramid
#include
#include
int main()
{
int
number, row, col;
int
displayNum;
printf("\nEnter
Number of Rows to be display : \n");
scanf("%d",
&number);
for
(row = 1; row <= number; row++)
{
displayNum
= 1;
for
(col = 1; col <= number; col++)
{
printf("%d\t",
displayNum++);
}
printf("\n");
}
return
0;
}
Output
Enter Number of Rows to be
display: 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
C Program to print decreasing rectangular pyramid
#include
#include
int main()
{
int
number, row, col;
int
displayNum;
printf("\nEnter
Number of Rows to be display : \n");
scanf("%d",
&number);
displayNum
= number;
for
(row = 1; row <= number; row++,displayNum--)
{
for
(col = 1; col <= number; col++)
printf("%d\t",
displayNum);
printf("\n");
}
return
0;
}
Output
Enter Number of Rows to be
display : 5
5 5 5 5 5
4 4 4 4 4
3 3 3 3 3
2 2 2 2 2
1 1 1 1 1
C Program to generate right angle pyramid
#include
#include
int main()
{
int
num, row = 1, i;
printf("Enter
number of rows : \n");
scanf("%d",
&num);
for
(row = 1 ; row <= num ; row++)
{
for
(i = 1; i <= row; i++)
{
printf("@
");
}
printf("\n");
}
return
0;
}
Output
Enter number of rows
: 6
@
@ @
@ @ @
@ @ @ @
@ @ @ @ @
@ @ @ @ @ @
C Program to generate right angle pyramid
#include
#include
int main()
{
int num, r =
1, i, space;
printf("Enter
number of rows : \n");
scanf("%d",
&num);
for (; num
>= 1; num--, r++)
{
for
(space = r; space > 1; space--)
{
printf("\t");
}
for
(i = 1; i <= num; i++)
{
printf("@\t");
}
printf("\n");
}
return 0;
}
Output
@ @ @ @ @
@ @ @ @
@ @ @
@ @
@
C Program to Print the Rectangle Pyramid of Numbers
#include
#include
int main()
{
int number,
row, col;
printf("\nEnter Number of Rows to be display : ");
scanf("%d", &number);
for (row = 1;
number >= row; row++)
{
for
(col = 1; col <= number; col++)
printf("%d\t", row);
printf("\n");
}
return
0;
}
Output
Enter Number of Rows to be
display : 5
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
C Program to Print the Rectangular Pyramid Pattern of Special Characters
#include
#include
int main()
{
int num, row,
column;
printf("\nEnter Number of Rows to be display : ");
scanf("%d", &num);
for (row = 1;
num >= row; row++)
{
for
(column = 1; column <= num; column++)
{
printf("# ");
}
printf("\n");
}
return
0;
}
Output
Enter Number of Rows to be
display : 4
# # # #
# # # #
# # # #
# # # #
No comments:
Post a Comment