SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
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;
}

Mais conteúdo relacionado

Mais procurados

Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CBUBT
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJSunil OS
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ projectUtkarsh Aggarwal
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and ConcurrencySunil OS
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectoriesBilal Amjad
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL Rishabh-Rawat
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxHome
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equationsAhmed Haider
 
Library Management Python, MySQL
Library Management Python, MySQLLibrary Management Python, MySQL
Library Management Python, MySQLDarshit Vaghasiya
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Hazrat Bilal
 
Term 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfTerm 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfKiranKumari204016
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station softwaredharmenderlodhi021
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)Nitish Yadav
 
Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)lokesh meena
 
Exception Handling
Exception HandlingException Handling
Exception HandlingSunil OS
 

Mais procurados (20)

Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
 
Class method
Class methodClass method
Class method
 
Project report
Project reportProject report
Project report
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectories
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptx
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
 
Library Management Python, MySQL
Library Management Python, MySQLLibrary Management Python, MySQL
Library Management Python, MySQL
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
 
Term 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfTerm 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdf
 
Scratch Basics
Scratch BasicsScratch Basics
Scratch Basics
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
 
Directional derivative and gradient
Directional derivative and gradientDirectional derivative and gradient
Directional derivative and gradient
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
 
Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)
 
Tic tac toe game code
Tic tac toe game codeTic tac toe game code
Tic tac toe game code
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 

Semelhante a C Program Print Pyramid Patterns

Semelhante a C Program Print Pyramid Patterns (20)

pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
C
CC
C
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 
Hargun
HargunHargun
Hargun
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++
 
C basics
C basicsC basics
C basics
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
C Programming
C ProgrammingC Programming
C Programming
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C program
C programC program
C program
 
Automata fix.pdf
Automata fix.pdfAutomata fix.pdf
Automata fix.pdf
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
C questions
C questionsC questions
C questions
 

Último

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Último (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

C Program Print Pyramid Patterns

  • 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; }