Pyramid Pattern Program in C - C Programming Tutorial 66

preview_player
Показать описание
Notes for You:: Pyramid Pattern Program in C - C Programming Tutorial 66

Example Code 1:
- Print Pyramid Pattern of Stars in C.
int row=0;
int col=0;
int totalRows=3;
int space=0;

for(row=1; row<=totalRows; row++)
{
for(space=1; space<=(totalRows-row); space++)
{
printf(" ");
}
for(col=1; col<=row; col++)
{
printf("* ");
}
printf("\n");
}
Output:
*
* *
* * *

Example Code 2:
- Print Pyramid Pattern of Numbers in C.
int row=0;
int col=0;
int totalRows=3;
int space=0;

for(row=1; row<=totalRows; row++)
{
for(space=1; space<=(totalRows-row); space++)
{
printf(" ");
}
for(col=1; col<=row; col++)
{
printf("%d ",row);
}
printf("\n");
}
Output:
1
2 2
3 3 3

Example Code 3:
- Print Pyramid Pattern of Numbers in C.
int row=0;
int col=0;
int totalRows=3;
int space=0;

for(row=1; row<=totalRows; row++)
{
for(space=1; space<=(totalRows-row); space++)
{
printf(" ");
}
for(col=1; col<=row; col++)
{
printf("%d ",col);
}
printf("\n");
}
Output:
1
1 2
1 2 3

Note:
- replace < with less-than symbol.

=========================================

Follow the link for next video:
C Programming Tutorial 67 - Arrays in C Programming Language

Follow the link for previous video:
C Programming Tutorial 65 - Print Triangle Pattern of Numbers and Stars in C Programming

=========================================

C Programming Tutorials Playlist:

=========================================
Watch My Other Useful Tutorials:-

Computer Programming Fundamentals Playlist:-

C Practical LAB Exercises Playlist:-

C++ Tutorials Playlist:

=========================================

► Subscribe to our YouTube channel:

► Visit our Website:

=========================================
Hash Tags:-
#ChidresTechTutorials #CProgramming #CProgrammingTutorial
Рекомендации по теме