SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Saikat Banerjee Page 1
Pattern Printing in C
Output :
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *_
Program :
/* Program to print pyramid pattern in C : Pattern 1
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr();
for(i=0; i<5; i++)
{
for(j=0; j<5; j++)
{
printf(" * ");
}
printf("n");
}
getch();
}
Output :
*
* *
* * *
* * * *
* * * * *_
Program :
/* Program to print pyramid pattern in C : Pattern 2
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr();
for(i=0; i<5; i++)
{
for(j=0; j<=i; j++)
Saikat Banerjee Page 2
{
printf(" * ");
}
printf("n");
}
getch();
}
Output :
*
* *
* * *
* * * *
* * * * *_
Program :
/* Program to print pyramid pattern in C : Pattern 3
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1; i<=5; i++)
{
for(j=5; j>=i; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("*");
}
printf("n");
}
getch();
}
Output :
* * * * *
* * * *
* * *
* *
*_
Program :
Saikat Banerjee Page 3
/* Program to print pyramid pattern in C : Pattern 4
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k,samp=1;
clrscr();
for(i=5; i>=1; i--)
{
for(k=samp; k>=0; k--)
{
printf(" "); // only 1 space
}
for(j=i; j>=1; j--)
{
printf("*");
}
samp = samp + 1;
printf("n");
}
getch();
}
or
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1; i<=5; i++)
{
for(j=5; j>=i; j--)
{
printf("*");
}
for(k=1; k<=i; k++)
{
printf(" ");
}
printf("n");
}
getch();
}
Output :
* * * * *
* * * *
* * *
* *
*_
Saikat Banerjee Page 4
Program :
/* Program to print pyramid pattern in C : Pattern 5
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr();
for(i=5; i>=1; i--)
{
for(j=1; j<=i; j++)
{
printf(" * ");
}
printf("n");
}
getch();
}
Output :
*
* *
* * *
* * * *
* * * * *_
Program :
/* Program to print pyramid pattern in C : Pattern 6
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k,t=0;
clrscr();
for(i=1; i<=5; i++)
{
for(k=t; k<5; k++)
{
printf(" ");
}
for(j=0; j< i; j++)
{
printf(" * ");
t = t + 1;
}
printf("n");
}
getch();
Saikat Banerjee Page 5
}
Output :
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*_
Program :
/* Program to print pyramid pattern in C : Pattern 7
Creation Date : 01:13 AM 22/11/2010
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k,samp=1;
clrscr();
for(i=1; i<=5; i++)
{
for(k=samp; k<=5; k++)
{
printf(" ");
}
for(j=0; j< i; j++)
{
printf("*");
}
samp = samp + 1;
printf("n");
}
samp = 1;
for(i=4; i>=1; i--)
{
for(k=samp; k>=0; k--)
{
printf(" ");
}
for(j=i; j>=1; j--)
{
printf("*");
}
samp = samp + 1;
printf("n");
}
getch();
Saikat Banerjee Page 6
}
Output :
Enter number of rows: 5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15_
Program :
/* Program to print pyramid pattern in C : Pattern 8
Creation Date : 02:39 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int rw, c, no=1 ,len;
clrscr();
printf("Enter number of rows: ");
scanf("%d," &len);
for(rw=1; rw<=len; rw++)
{
printf("n");
for(c=1; c<=rw; c++)
{
printf(" %2d ", no);
no++;
}
}
getch();
}
Output :
Enter number of rows: 5
0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5_
Program :
Saikat Banerjee Page 7
/* Program to print pyramid pattern in C : Pattern 9
Creation Date : 03:19 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int no,i,y,x=35;
clrscr();
printf("Enter number of rows: ");
scanf("%d," &no);
for(y=0;y<=no;y++)
{
goto(x,y+1);
for(i=0-y; i<=y; i++)
{
printf(" %3d ", abs(i));
x=x-3;
}
}
getch();
}
Output :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5_
Program :
/* Program to print pyramid pattern in C : Pattern 10
Creation Date : 03:14 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int i, j=5, k, x;
clrscr();
for(i=1;i<=5;i++)
{
for(k=1;k<=j;k++)
{
printf(" ");
}
for(x=1;x<=i;x++)
Saikat Banerjee Page 8
{
printf("%d",i);
printf(" ");
}
printf("n");
j=j-1;
}
getch();
}
Output :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5_
Program :
/* Program to print pyramid pattern in C : Pattern 11
Creation Date : 03:24 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int rw,c,no,spc;
clrscr();
printf("Enter number of rows : ");
scanf("%d", &no);
for(rw=1; rw<=no; rw++)
{
for(spc=no; spc>=rw; spc--)
{
printf(" ");
}
for(c=1; c<=rw; c++)
{
printf("%2d",c);
}
printf("n");
}
getch();
}
Output :
Saikat Banerjee Page 9
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9_
Program :
/* Program to print pyramid pattern in C : Pattern 12
Creation Date : 03:24 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1; i<=5; i++)
{
for(j=1; j<=5-i; j++)
{
printf(" ");
}
for(k=1; k<=2*i-1; k++)
{
printf(" %d ",k);
}
printf("n");
}
getch();
}
Output :
A B C D E F G G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A_
Program :
/* Program to print pyramid pattern in C : Pattern 13
Creation Date : 04:24 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
Saikat Banerjee Page 10
{
int i,j,asci,spc;
clrscr();
for(i=7; i>=1; i--)
{
for(spc=6; spc>=i; spc--)
{
printf(" ");
}
asci=65;
for(j=1; j<=i; j++)
{
printf("%2c",asci++);
}
for(j=i-1; j>=0; j--)
{
printf("%2c",--asci);
}
printf("n");
}
getch();
}
Output :
AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB
BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_
Program :
/* Program to print all Combinations of characters
A, B, C : Pattern 14
Creation Date : 11:33 PM 01/10/2011
Author : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h>
#include <conio.h>
void main()
{
char ch1, ch2, ch3;
clrscr();
for(ch1='A' ; ch1<='C' ; ++ch1)
{
for(ch2='A' ; ch2<='C' ; ++ch2)
{
for(ch3='A' ; ch3<='C' ; ++ch3)
{
printf(" %c%c%c", ch1, ch2, ch3);
}
}
}
getch();
Saikat Banerjee Page 11
}
 Write a C program to print the following pattern:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
Program:
#include <stdio.h>
int main(void) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j <= i; j++) {
if (((i + j) % 2) == 0) { // Decides on as to which digit to print.
printf("0");
} else {
printf("1");
}
printf("t");
}
printf("n");
}
return 0;
}
 Write C program to print the following pattern:
0
1 1
2 3 5
8 13 21
Program:
#include <stdio.h>
int main(void) {
int i, j, a = 0, b = 1, temp = 1;
for (i = 1; i <= 4; i++) {
for (j = 1; j <= i; j++) {
if (i == 1 && j == 1) { // Prints the '0' individually first
printf("0");
continue;
}
printf("%d ", temp); // Prints the next digit in the series
//Computes the series
temp = a + b;
a = b;
b = temp;
if (i == 4 && j == 3) { // Skips the 4th character of the base
break;
}
}
printf("n");
}
return 0;
}
Saikat Banerjee Page 12
 Write C program to print the following pattern:
1
121
12321
1234321
12321
121
1
Program:
#include <stdio.h>
void sequence(int x);
int main() {
/* c taken for columns */
int i, x = 0, num = 7;
for (i = 1; i <= num; i++) {
if (i <= (num / 2) + 1) {
x = i;
} else {
x = 8 - i;
}
sequence(x);
puts("n");
}
return 0;
}
void sequence(int x) {
int j;
for (j = 1; j < x; j++) {
printf("%d", j);
}
for (j = x; j > 0; j--) {
printf("%d", j);
}
}
 Write a C program to print the following pattern:
77777777777
7
7
7
7
7
7
7
7
7
7
Program:
#include <stdio.h>
int main(void) {
int i, j;
for (i = 11; i >= 1; i--) {
for (j = 1; j <= i; j++) {
if (i == 11) {
Saikat Banerjee Page 13
printf("7"); // Makes sure the base is printed completely
continue;
} else if (j == i) { // Hollows the rest
printf("7");
} else {
printf(" ");
}
}
printf("n");
}
return 0;
}
 Write a C program to print the following pattern:
1
2 4
3 6 9
2 4
1
Program:
#include <stdio.h>
int main(void) {
int i,j;
for (i=1; i<=3 ; i++) {
for (j=1; j<=i; j++) {
printf("%2d", (i*j));
}
printf("n");
}
for (i=2; i>=1; i--) { // As they share the same base
for (j=1; j<=i; j++) {
printf("%2d",i*j);
}
printf("n");
}
return 0;
}
 Write a C program to print the following pattern:
1
1 0
1 0 0
1 0 0 0
1 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0
1 0 0 0
1 0 0
1 0
1
Program:
#include <stdio.h>
Saikat Banerjee Page 14
int main(void) {
int i,j;
for (i=1; i<=7; i++) {
for (j=1; j<=i; j++) {
if (j==1) { // Applying the condition
printf(" 1");
} else {
printf(" 0");
}
}
printf("n");
}
for (i=6; i>=1; i--) { //As it shares the same base i=6
for (j=1; j<=i; j++) {
if (j==1) { // Applying the condition
printf(" 1");
} else {
printf(" 0");
}
}
printf("n");
}
return 0;
}

More Related Content

PPTX
C++ Overview PPT
Thooyavan Venkatachalam
 
PPT
File in C Programming
Sonya Akter Rupa
 
PPTX
Preprocessor directives in c language
tanmaymodi4
 
PPTX
C functions
University of Potsdam
 
PPTX
physical and logical data independence
apoorva_upadhyay
 
PPT
C Structures And Unions
Ram Sagar Mourya
 
PPTX
classes and objects in C++
HalaiHansaika
 
C++ Overview PPT
Thooyavan Venkatachalam
 
File in C Programming
Sonya Akter Rupa
 
Preprocessor directives in c language
tanmaymodi4
 
physical and logical data independence
apoorva_upadhyay
 
C Structures And Unions
Ram Sagar Mourya
 
classes and objects in C++
HalaiHansaika
 

What's hot (20)

PPT
File in c
Prabhu Govind
 
PPTX
Data structures
MADHAVASAIYENDUVA
 
PPTX
Operator Overloading & Type Conversions
Rokonuzzaman Rony
 
DOCX
Write a program to print out all armstrong numbers between 1 and 500
ilsamaryum
 
PPTX
Function C programming
Appili Vamsi Krishna
 
PDF
Constructors and destructors
Nilesh Dalvi
 
PPTX
Quick_sort1.pptx
sandeep54552
 
PPTX
Dynamic Polymorphism in C++
Dharmisha Sharma
 
PPTX
What is c
Nitesh Saitwal
 
PPTX
Function template
Kousalya M
 
PPTX
POINTERS IN C
Neel Mungra
 
PDF
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
rohit kumar
 
PPTX
C programming - String
Achyut Devkota
 
PDF
Function overloading ppt
Prof. Dr. K. Adisesha
 
PDF
C Pointers
omukhtar
 
PPTX
Pointers in c language
Tanmay Modi
 
PPTX
Array in c++
Mahesha Mano
 
PPTX
String in c programming
Devan Thakur
 
PPTX
OOPS Basics With Example
Thooyavan Venkatachalam
 
File in c
Prabhu Govind
 
Data structures
MADHAVASAIYENDUVA
 
Operator Overloading & Type Conversions
Rokonuzzaman Rony
 
Write a program to print out all armstrong numbers between 1 and 500
ilsamaryum
 
Function C programming
Appili Vamsi Krishna
 
Constructors and destructors
Nilesh Dalvi
 
Quick_sort1.pptx
sandeep54552
 
Dynamic Polymorphism in C++
Dharmisha Sharma
 
What is c
Nitesh Saitwal
 
Function template
Kousalya M
 
POINTERS IN C
Neel Mungra
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
rohit kumar
 
C programming - String
Achyut Devkota
 
Function overloading ppt
Prof. Dr. K. Adisesha
 
C Pointers
omukhtar
 
Pointers in c language
Tanmay Modi
 
Array in c++
Mahesha Mano
 
String in c programming
Devan Thakur
 
OOPS Basics With Example
Thooyavan Venkatachalam
 
Ad

Similar to pattern-printing-in-c.pdf (20)

PPTX
Simple c program
Ravi Singh
 
PDF
Automata fix.pdf
sudarshanhacker
 
PPTX
C program language tutorial pattern printing
Sourav Ganguly
 
PPTX
Learn How to create pyramids in c
Harish Gyanani
 
DOCX
C programs
vijaybandi36
 
DOCX
Lab. Programs in C
Saket Pathak
 
PDF
C Language Lecture 8
Shahzaib Ajmal
 
PDF
Common problems solving using c
ArghodeepPaul
 
PDF
PCA-2 Programming and Solving 2nd Sem.pdf
Ashutoshprasad27
 
DOCX
PCA-2 Programming and Solving 2nd Sem.docx
Ashutoshprasad27
 
PDF
Aguirre.Module2.Problemset.pdf
CarlChristopherFunda
 
PDF
chapter-5: C-Programming by "Ratul Rana Sir", Ullapara, Sirajganj
Math Vision
 
PDF
Cp manual final
itprasad1237
 
DOC
C-programs
SSGMCE SHEGAON
 
PDF
Simple C programs
ab11cs001
 
DOCX
Hargun
Mukund Trivedi
 
PPTX
C-LOOP-Session-2.pptx
Sarkunavathi Aribal
 
PPTX
Implemintation of looping programs......
anjanasharma77573
 
DOCX
B.Com 1year Lab programs
Prasadu Peddi
 
Simple c program
Ravi Singh
 
Automata fix.pdf
sudarshanhacker
 
C program language tutorial pattern printing
Sourav Ganguly
 
Learn How to create pyramids in c
Harish Gyanani
 
C programs
vijaybandi36
 
Lab. Programs in C
Saket Pathak
 
C Language Lecture 8
Shahzaib Ajmal
 
Common problems solving using c
ArghodeepPaul
 
PCA-2 Programming and Solving 2nd Sem.pdf
Ashutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
Ashutoshprasad27
 
Aguirre.Module2.Problemset.pdf
CarlChristopherFunda
 
chapter-5: C-Programming by "Ratul Rana Sir", Ullapara, Sirajganj
Math Vision
 
Cp manual final
itprasad1237
 
C-programs
SSGMCE SHEGAON
 
Simple C programs
ab11cs001
 
C-LOOP-Session-2.pptx
Sarkunavathi Aribal
 
Implemintation of looping programs......
anjanasharma77573
 
B.Com 1year Lab programs
Prasadu Peddi
 
Ad

More from RSathyaPriyaCSEKIOT (12)

PPTX
seminar on web technology with cloud service
RSathyaPriyaCSEKIOT
 
PPTX
structure query language with DATABASE MANAGEMENT
RSathyaPriyaCSEKIOT
 
PPTX
INNER PRODUCT SPACE in underwater system
RSathyaPriyaCSEKIOT
 
PPTX
c programming session 1.pptx
RSathyaPriyaCSEKIOT
 
PPTX
UNIT I_PSPP - Illustrative Problems (1).pptx
RSathyaPriyaCSEKIOT
 
PDF
unit-2 mc.pdf
RSathyaPriyaCSEKIOT
 
PDF
unit-1 notes
RSathyaPriyaCSEKIOT
 
PDF
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
PDF
C program full materials.pdf
RSathyaPriyaCSEKIOT
 
seminar on web technology with cloud service
RSathyaPriyaCSEKIOT
 
structure query language with DATABASE MANAGEMENT
RSathyaPriyaCSEKIOT
 
INNER PRODUCT SPACE in underwater system
RSathyaPriyaCSEKIOT
 
c programming session 1.pptx
RSathyaPriyaCSEKIOT
 
UNIT I_PSPP - Illustrative Problems (1).pptx
RSathyaPriyaCSEKIOT
 
unit-2 mc.pdf
RSathyaPriyaCSEKIOT
 
unit-1 notes
RSathyaPriyaCSEKIOT
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
C program full materials.pdf
RSathyaPriyaCSEKIOT
 

Recently uploaded (20)

PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PPTX
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPT
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Information Retrieval and Extraction - Module 7
premSankar19
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
Zero Carbon Building Performance standard
BassemOsman1
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 

pattern-printing-in-c.pdf

  • 1. Saikat Banerjee Page 1 Pattern Printing in C Output : * * * * * * * * * * * * * * * * * * * * * * * * *_ Program : /* Program to print pyramid pattern in C : Pattern 1 #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=0; i<5; i++) { for(j=0; j<5; j++) { printf(" * "); } printf("n"); } getch(); } Output : * * * * * * * * * * * * * * *_ Program : /* Program to print pyramid pattern in C : Pattern 2 #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=0; i<5; i++) { for(j=0; j<=i; j++)
  • 2. Saikat Banerjee Page 2 { printf(" * "); } printf("n"); } getch(); } Output : * * * * * * * * * * * * * * *_ Program : /* Program to print pyramid pattern in C : Pattern 3 #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=5; j>=i; j--) { printf(" "); } for(k=1; k<=i; k++) { printf("*"); } printf("n"); } getch(); } Output : * * * * * * * * * * * * * * *_ Program :
  • 3. Saikat Banerjee Page 3 /* Program to print pyramid pattern in C : Pattern 4 #include <stdio.h> #include <conio.h> void main() { int i,j,k,samp=1; clrscr(); for(i=5; i>=1; i--) { for(k=samp; k>=0; k--) { printf(" "); // only 1 space } for(j=i; j>=1; j--) { printf("*"); } samp = samp + 1; printf("n"); } getch(); } or #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=5; j>=i; j--) { printf("*"); } for(k=1; k<=i; k++) { printf(" "); } printf("n"); } getch(); } Output : * * * * * * * * * * * * * * *_
  • 4. Saikat Banerjee Page 4 Program : /* Program to print pyramid pattern in C : Pattern 5 #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=5; i>=1; i--) { for(j=1; j<=i; j++) { printf(" * "); } printf("n"); } getch(); } Output : * * * * * * * * * * * * * * *_ Program : /* Program to print pyramid pattern in C : Pattern 6 #include <stdio.h> #include <conio.h> void main() { int i,j,k,t=0; clrscr(); for(i=1; i<=5; i++) { for(k=t; k<5; k++) { printf(" "); } for(j=0; j< i; j++) { printf(" * "); t = t + 1; } printf("n"); } getch();
  • 5. Saikat Banerjee Page 5 } Output : * * * * * * * * * * * * * * * * * * * * * * * * *_ Program : /* Program to print pyramid pattern in C : Pattern 7 Creation Date : 01:13 AM 22/11/2010 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int i,j,k,samp=1; clrscr(); for(i=1; i<=5; i++) { for(k=samp; k<=5; k++) { printf(" "); } for(j=0; j< i; j++) { printf("*"); } samp = samp + 1; printf("n"); } samp = 1; for(i=4; i>=1; i--) { for(k=samp; k>=0; k--) { printf(" "); } for(j=i; j>=1; j--) { printf("*"); } samp = samp + 1; printf("n"); } getch();
  • 6. Saikat Banerjee Page 6 } Output : Enter number of rows: 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15_ Program : /* Program to print pyramid pattern in C : Pattern 8 Creation Date : 02:39 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int rw, c, no=1 ,len; clrscr(); printf("Enter number of rows: "); scanf("%d," &len); for(rw=1; rw<=len; rw++) { printf("n"); for(c=1; c<=rw; c++) { printf(" %2d ", no); no++; } } getch(); } Output : Enter number of rows: 5 0 1 0 1 2 1 0 1 2 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5_ Program :
  • 7. Saikat Banerjee Page 7 /* Program to print pyramid pattern in C : Pattern 9 Creation Date : 03:19 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int no,i,y,x=35; clrscr(); printf("Enter number of rows: "); scanf("%d," &no); for(y=0;y<=no;y++) { goto(x,y+1); for(i=0-y; i<=y; i++) { printf(" %3d ", abs(i)); x=x-3; } } getch(); } Output : 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5_ Program : /* Program to print pyramid pattern in C : Pattern 10 Creation Date : 03:14 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int i, j=5, k, x; clrscr(); for(i=1;i<=5;i++) { for(k=1;k<=j;k++) { printf(" "); } for(x=1;x<=i;x++)
  • 8. Saikat Banerjee Page 8 { printf("%d",i); printf(" "); } printf("n"); j=j-1; } getch(); } Output : 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5_ Program : /* Program to print pyramid pattern in C : Pattern 11 Creation Date : 03:24 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int rw,c,no,spc; clrscr(); printf("Enter number of rows : "); scanf("%d", &no); for(rw=1; rw<=no; rw++) { for(spc=no; spc>=rw; spc--) { printf(" "); } for(c=1; c<=rw; c++) { printf("%2d",c); } printf("n"); } getch(); } Output :
  • 9. Saikat Banerjee Page 9 1 1 2 3 1 2 3 4 5 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9_ Program : /* Program to print pyramid pattern in C : Pattern 12 Creation Date : 03:24 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=1; j<=5-i; j++) { printf(" "); } for(k=1; k<=2*i-1; k++) { printf(" %d ",k); } printf("n"); } getch(); } Output : A B C D E F G G F E D C B A A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A_ Program : /* Program to print pyramid pattern in C : Pattern 13 Creation Date : 04:24 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main()
  • 10. Saikat Banerjee Page 10 { int i,j,asci,spc; clrscr(); for(i=7; i>=1; i--) { for(spc=6; spc>=i; spc--) { printf(" "); } asci=65; for(j=1; j<=i; j++) { printf("%2c",asci++); } for(j=i-1; j>=0; j--) { printf("%2c",--asci); } printf("n"); } getch(); } Output : AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_ Program : /* Program to print all Combinations of characters A, B, C : Pattern 14 Creation Date : 11:33 PM 01/10/2011 Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> void main() { char ch1, ch2, ch3; clrscr(); for(ch1='A' ; ch1<='C' ; ++ch1) { for(ch2='A' ; ch2<='C' ; ++ch2) { for(ch3='A' ; ch3<='C' ; ++ch3) { printf(" %c%c%c", ch1, ch2, ch3); } } } getch();
  • 11. Saikat Banerjee Page 11 }  Write a C program to print the following pattern: 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 Program: #include <stdio.h> int main(void) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j <= i; j++) { if (((i + j) % 2) == 0) { // Decides on as to which digit to print. printf("0"); } else { printf("1"); } printf("t"); } printf("n"); } return 0; }  Write C program to print the following pattern: 0 1 1 2 3 5 8 13 21 Program: #include <stdio.h> int main(void) { int i, j, a = 0, b = 1, temp = 1; for (i = 1; i <= 4; i++) { for (j = 1; j <= i; j++) { if (i == 1 && j == 1) { // Prints the '0' individually first printf("0"); continue; } printf("%d ", temp); // Prints the next digit in the series //Computes the series temp = a + b; a = b; b = temp; if (i == 4 && j == 3) { // Skips the 4th character of the base break; } } printf("n"); } return 0; }
  • 12. Saikat Banerjee Page 12  Write C program to print the following pattern: 1 121 12321 1234321 12321 121 1 Program: #include <stdio.h> void sequence(int x); int main() { /* c taken for columns */ int i, x = 0, num = 7; for (i = 1; i <= num; i++) { if (i <= (num / 2) + 1) { x = i; } else { x = 8 - i; } sequence(x); puts("n"); } return 0; } void sequence(int x) { int j; for (j = 1; j < x; j++) { printf("%d", j); } for (j = x; j > 0; j--) { printf("%d", j); } }  Write a C program to print the following pattern: 77777777777 7 7 7 7 7 7 7 7 7 7 Program: #include <stdio.h> int main(void) { int i, j; for (i = 11; i >= 1; i--) { for (j = 1; j <= i; j++) { if (i == 11) {
  • 13. Saikat Banerjee Page 13 printf("7"); // Makes sure the base is printed completely continue; } else if (j == i) { // Hollows the rest printf("7"); } else { printf(" "); } } printf("n"); } return 0; }  Write a C program to print the following pattern: 1 2 4 3 6 9 2 4 1 Program: #include <stdio.h> int main(void) { int i,j; for (i=1; i<=3 ; i++) { for (j=1; j<=i; j++) { printf("%2d", (i*j)); } printf("n"); } for (i=2; i>=1; i--) { // As they share the same base for (j=1; j<=i; j++) { printf("%2d",i*j); } printf("n"); } return 0; }  Write a C program to print the following pattern: 1 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 1 Program: #include <stdio.h>
  • 14. Saikat Banerjee Page 14 int main(void) { int i,j; for (i=1; i<=7; i++) { for (j=1; j<=i; j++) { if (j==1) { // Applying the condition printf(" 1"); } else { printf(" 0"); } } printf("n"); } for (i=6; i>=1; i--) { //As it shares the same base i=6 for (j=1; j<=i; j++) { if (j==1) { // Applying the condition printf(" 1"); } else { printf(" 0"); } } printf("n"); } return 0; }