Geeksquiz: Program To Print A Pattern of Numbers
Geeksquiz: Program To Print A Pattern of Numbers
ComputerScienceQuizzesforGeeks!
GATECS
CodingPractice
Placements GeeksforGeeks
Programtoprintapatternofnumbers
Theideaofpatternbasedprogramsistounderstandtheconceptofnestingofforloopsandhowandwheretoplace
thealphabets/numbers/starstomakethedesiredpattern.
Writetoprogramtoprintthepatternofnumbersinthefollowingmannerusingforloop
1
232
34543
4567654
567898765
Inalmostalltypesofpatternprograms,twothingsthatyoumusttakecare:
1.No.oflines
2.Ifthepatternisincreasingordecreasingperline?
Implementation
#include<stdio.h>
main()
{
intn=5,i,j,num=1,gap;
gap=n1;
for(j=1;j<=n;j++)
{
num=j;
for(i=1;i<=gap;i++)
printf("");
gap;
for(i=1;i<=j;i++)
{
printf("%d",num);
num++;
}
num;
num;
for(i=1;i<j;i++)
{
printf("%d",num);
num;
}
printf("\n");
return0;
}
RunonIDE
ProgramforPyramidPattern
Pleasewritecommentsifyoufindanythingincorrect,oryouwanttosharemoreinformationaboutthetopicdiscussed
above
SeePlacementCourse for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all
QuizzesonGeeksQuiz.
(LogintoRateandMark)
AverageRating:0/5.0
AverageDifficulty:1/5.0
Basedon1vote(s)
Novotesyet.
AddtoTODOList
MarkasDONE
LoadComments
@geeksforgeeksSomerightsreservedContactUs!AboutUs!PrivacyPolicy