top of page
Search

# Pyramids and Patterns Programs in C

Updated: Aug 14, 2022

## 1. Half Pyramid of * programs in C

*

* *

* * *

* * * *

* * * * *

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

clrscr();

for (i = 1; i <= 5; ++i)

{

for (j = 1; j <= i; ++j)

{

printf("* ");

}

printf("\n");

}

getch();

}

### 2. C program of Inverted half pyramid of *

* * * * *

* * * *

* * *

* *

*

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

for (i = 5; i >= 1; --i)

{

for (j = 1; j <= i; ++j)

{

printf("* ");

}

printf("\n");

}

getch();

}

### 3. C program for Half Pyramid of Numbers

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

clrscr();

for (i = 1; i <= 5; ++i)

{

for (j = 1; j <= i; ++j)

{

printf("%d ", j);

}

printf("\n");

}

getch();

}

### 4. C Program for Inverted half pyramid of numbers:

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

for (i = 5; i >= 1; --i)

{

for (j = 1; j <= i; ++j)

{

printf("%d ", j);

}

printf("\n");

}

getch();

}

### 5. C program for Half Pyramid of Alphabets:

A

B B

C C C

D D D D

E E E E E

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

for (i = 1; i <= 5; i++)

{

for (j = 1; j <= i;j++)

{

printf("%c ", 'A'-1+i);

}

printf("\n");

}

getch();

}

### 6.C Program for Alphabet pattern:

A

AB

ABC

ABCD

ABCDE

Program:

#include<stdio.h>

#include<conio.h>

void main()

{

int i, j;

for(i=1;i<=5;i++)

{

for(j=1;j<=i;j++)

{

printf("%c",'A' + j-1);

}

printf("\n");

}

getch();

}

### 7. C Program for Alphabet pattern:

A

BA

CBA

DCBA

EDCBA

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

for(i=1;i<=5;i++)

{

for(j=i;j>=1;j--)

{

printf("%c",'A' + j-1);

}

printf("\n");

}

getch();

}

### 8. C Program Alphabet pattern:

EEEEE

DDDD

CCC

BB

A

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, j;

for(i=5;i>=1;i--)

{

for(j=1;j<=i;j++)

{

printf("%c",'A'-1 + i);

}

printf("\n");

}

getch();

}

### 9. C program for below Alphabet pattern:

A

BC

DEF

GHIJ

KLMNO

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i,j;

char ch='A';

for(i=1;i<=5;i++)

{

for(j=1;j<=i;j++)

{

printf("%c ",ch++);

}

printf("\n");

}

getch();

}

### 10. C Program for Alphabet pattern below:

A

ABC

ABCDE

ABCDEFG

ABCDEFGI

Program:

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n=5;

for(i=1;i<=n;i++)

{

for(j=1;j<=(i*2-1);j++)

{

printf("%c",(char)(j+64));

}

printf("\n");

}

getch();

}

### 11. C Program for below Full Pyramid of *

*

* * *

* * * * *

* * * * * * *

* * * * * * * * *

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

int i, space, k = 0;

for (i = 1; i <= 5; ++i, k = 0)

{

for (space = 1; space <= 5 - i; ++space)

{

printf(" ");

}

while (k != 2 * i - 1)

{

printf("* ");

++k;

}

printf("\n");

}

getch();

}