0% found this document useful (0 votes)
34 views

Geeksquiz: Program To Print A Pattern of Numbers

This document provides an example C program to print a numeric pyramid pattern using nested for loops. It explains that pattern programs require considering the number of lines and whether the pattern increases or decreases per line. The example program prints a pyramid from 1 to 9 that increases on each line then decreases. Comments are welcomed to provide feedback or additional information. The site contains other C programs and quizzes for computer science learning.

Uploaded by

ShinyShiny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Geeksquiz: Program To Print A Pattern of Numbers

This document provides an example C program to print a numeric pyramid pattern using nested for loops. It explains that pattern programs require considering the number of lines and whether the pattern increases or decreases per line. The example program prints a pyramid from 1 to 9 that increases on each line then decreases. Comments are welcomed to provide feedback or additional information. The site contains other C programs and quizzes for computer science learning.

Uploaded by

ShinyShiny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GeeksQuiz

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.

Category: C Programs Tags: C

(LogintoRateandMark)
AverageRating:0/5.0
AverageDifficulty:1/5.0

Basedon1vote(s)

Novotesyet.

AddtoTODOList

MarkasDONE

LoadComments
@geeksforgeeksSomerightsreservedContactUs!AboutUs!PrivacyPolicy

You might also like