Introduction
Pattern programs are a crucial part of coding interviews and practice sessions. They help improve logical thinking and understand loop concepts in various programming languages. In this article, we will discuss different star, numeric, and character (alphabet) pattern programs in C, Java, C++, and Python with their outputs.
Table of Contents
Star Pattern Programs in C | C++ | Java | Python
*
**
***
****
*****
2. Write a Program to print an inverted right triangle star pattern.
*****
****
***
**
*
*
**
***
****
*****
4. Write a Program to print the Inverted Half Pyramid Star Pattern.
*****
****
***
**
*
*
* *
* * *
* * * *
* * * * *
6. Write a Program to print an inverted pyramid star pattern.
* * * * *
* * * *
* * *
* *
*
7. Write a Program to print a square star pattern.
*****
*****
*****
*****
*****
8. Write a Program to Print Half Diamond Star Pattern.
*
**
***
****
*****
****
***
**
*
9. Write a program to Print a solid Diamond Star Pattern.
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
*
* *
* *
* *
* *
11. Write a Program to print the Full Pyramid Star Pattern.
*
***
*****
*******
*********
12. Write a Program to Print the Inverted Full Pyramid Star Pattern.
*********
*******
*****
***
*
13. Write a Program to print the Solid Inverted Half Diamond Star Pattern.
*
**
***
****
*****
******
*****
****
***
**
*
14. Write a Program to Print the V Star Pattern.
* *
* *
* *
* *
*
*
* *
* *
* *
* *
* *
*
16. Write a Program to Print the Pant's style Star Pattern.
*********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
*********
******
*****
****
***
**
*
**
***
****
*****
******
* *
* *
*
* *
* *
*****
* *
* *
* *
*****
* *
** **
*** ***
*******
*** ***
** **
* *
Number Pattern Program in C | CPP | Java | Python
1. Write a program to print the rectangle Number pattern.
11111
22222
33333
44444
55555
2. Write a program to print the rectangle Number pattern.
12345
12345
12345
12345
12345
3. Write a program to print the rectangle Number pattern.
55555
44444
33333
22222
11111
4. Write a program to print the rectangle Number pattern.
54321
54321
54321
54321
54321
5. Write a Program to print the Half Pyramid Number Pattern.
1
22
333
4444
55555
6. Write a Program to print the Half Pyramid Number Pattern.
1
12
123
1234
12345
7. Write a Program to print the Half Pyramid Number Pattern.
11111
2222
333
44
5
8. Write a Program to print the Inverted Half Pyramid Number Pattern.
12345
1234
123
12
1
9. Write a Program to print the Full Pyramid Number Pattern.
1
222
33333
4444444
555555555
10. Write a Program to print the Full Pyramid Number Pattern.
1
333
55555
7777777
999999999
11. Write a Program to print the Full Pyramid Number Pattern.
1
123
12345
1234567
123456789
1
321
54321
7654321
987654321
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
1
2 2
3 3
4 4
5 5
5 5
4 4
3 3
2 2
1
5
54
543
5432
54321
543210
54321
5432
543
54
5
5
45
345
2345
12345
012345
12345
2345
345
45
5
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
1 1
2 2
3
4 4
5 5
1
1 2
3 5 8
13 21 34 55
89 144 233 377 610
1 7
12 67
123 567
1234567
123 567
12 67
1 7
1
22
3 3
4 4
55555
1 2 34 5 67 8 9 1011 12 13 14 15
Alphabet Pattern Programs in C | C++ | Python | Java
1. Write a program to print the rectangle alphabet pattern.
AAAAA
BBBBB
CCCCC
DDDDD
EEEEE
A B C D E
A B C D E
A B C D E
A B C D E
A B C D E
3. Write a program to print the rectangle alphabet pattern.
E E E E E
D D D D D
C C C C C
B B B B B
A A A A A
4. Write a program to print the rectangle alphabet pattern.
E D C B A
E D C B A
E D C B A
E D C B A
E D C B A
5. Write a program to print the Alphabet Half Pyramid Pattern.
A
B B
C C C
D D D D
E E E E E
6. Write a Program to print the right triangle Alphabet Pattern.
A
A B
A B C
A B C D
A B C D E
7. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
E E E E E
D D D D
C C C
B B
A
8. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
A B C D E
A B C D
A B C
A B
A
9. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
A A A A A
B B B B
C C C
D D
E
10. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
E D C B A
E D C B
E D C
E D
E
11. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
A
BB
CCC
DDDD
EEEEE
12. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
A
AB
ABC
ABCD
ABCDE
13. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
ABCDE
ABCD
ABC
AB
A
14. Write a program to print the Alphabet Inverted Half Pyramid Pattern.
ABCDE
ABCD
ABC
AB
A
A
BBB
CCCCC
DDDDDDD
EEEEEEEEE
EEEEEEEEE
DDDDDDD
CCCCC
BBB
A
F
FE
FED
FEDC
FEDCB
FEDCBA
FEDCB
FEDC
FED
FE
F
F
EF
DEF
CDEF
BCDEF
ABCDEF
BCDEF
CDEF
DEF
EF
F
A
B B
C C C
D D D D
E E E E E
F F F F F F
E E E E E
D D D D
C C C
B B
A
E E
D D
C C
B B
A
38 Comments
can you tell me this pattern
ReplyDelete1
AB
123
ABCD
12345
ABCDEF
in python ASAP!!!!
size=int(input("Enter your size"))
Deletefor out in range(1,size+1):
for inn in range(1,out+1):
if out%2==0:
print(chr(inn+64),end="")
else:
print(inn,end"")
print("\r")
In C also plz
Deletehow to print
ReplyDelete1 A A A A
2 2 B B B
3 3 3 C C
4 4 4 4 D
in java??
n=int(input())
Deletenum=1
ch=str(input())
for i in range(n):
for i in range(i+1):
print(num,end=' ')
num+=1
for i in range(0,n-i):
print(ch,end=' ')
d=ord(ch)
d+=1
ch=chr(d)
print()
for (int i = 0; i < 4; i++) {
Deletefor (int j = 0; j < 5; j++) {
if (i >= j) {
System.out.print(i + 1 + " ");
}else {
System.out.print((char)(i+65)+" ");
}
}
System.out.println();
}
4444
ReplyDelete3444
2344
1234
can you do this in python
k=4
Deletefor i in range(4):
p=k
for j in range(i):
print(p,end=" ")
p=p+1
k=k-1
for j in range(i,4):
print("4",end=" ")
print()
#include
ReplyDeleteint main()
{
int i, j, k;
char ch;
for(i=1; i<=6; i++)
{
ch='A';
if(i%2!=0)
{
for(k=1; k<=i; k++)
{
printf("%d", k);
}
}
else
{
for(j=1; j<=i; j++)
{
printf("%c", ch);
ch++;
}
}
printf("\n");
}
return 0;
}
can u tell me pattern
ReplyDelete4444
3444
2344
1234
// 4444
Delete// 3444
// 2344
// 1234
#include
int main()
{
int limit=4, out, ins;
for (out = 1; out <=limit; out++)
{
for (ins = 1; ins <= limit; ins++)
{
if(ins<out)
printf("%d",limit+ins-out);
else
printf("%d",limit);
}
printf("\n");
}
return 0;
}
Code for
ReplyDelete1
21
123
4321
12345
// 1
Delete// 21
// 123
// 4321
// 12345
#include
int main()
{
int limit=5, out, ins;
for (out = 1; out <=limit; out++)
{
for (ins = 1; ins <= out; ins++)
{
if(out%2==0)
printf("%d",out-ins+1);
else
printf("%d",ins);
}
printf("\n");
}
return 0;
}
how to print
ReplyDelete*+*+*
+*+*+
*+*+*
+*+*+
*+*+*
// *+*+*
Delete// +*+*+
// *+*+*
// +*+*+
// *+*+*
#include
int main()
{
int limit=5, out, ins;
for (out = 1; out <=limit; out++)
{
for (ins = 1; ins <= limit; ins++)
{
if(out%2==0)
{
if(ins%2==0)
printf("*");
else
printf("+");
}
else{
if(ins%2==0)
printf("+");
else
printf("*");
}
}
printf("\n");
}
return 0;
}
1
ReplyDelete24
135
2468
13579
Can you please tell this pattern in c++?
#include
Deleteusing namespace std;
int main()
{
int in, out, pr;
for (out = 1; out <= 5; out++)
{
if (out % 2 != 0)
pr = 1;
else
pr = 2;
for (in = 1; in <= out; in++)
{
cout <<pr<<" ";
pr += 2;
}
cout << "\n";
}
}
Enter no of rows: 5
ReplyDeleteEnter no of columns: 5
Result:
ABCDE
F G
H I
J K
LMNOP
1
ReplyDeleteAB
123
ABCD
12345
ABCDEF
asap in java please !!
public class P1 {
Deletepublic static void main(String[] args) {
int in, out;
for (out = 1; out <= 6; out++) {
for (in = 1; in <= out; in++) {
if (out % 2 != 0)
System.out.print(in + " ");
else
System.out.print((char) (in + 64) + " ");
}
System.out.println();
}
}
}
This comment has been removed by the author.
ReplyDelete(a)
ReplyDelete(a + b)
(a + b + c)
(a + b + c + d)
(a + b + c + d + e)
(a + b + c + d + e + f)
please print this in java asap!!
for (int i = 0; i < 6; i++) {
DeleteStringJoiner jn = new StringJoiner("+", "(", ")");
for (int j = 0; j <= i; j++) {
jn.add(""+(char) (97 + j));
}
System.out.println(jn);
}
Write a program in C to display the following pattern
ReplyDelete1 2 3 4 5
6 7 8 9
10 11 12
13
A1
ReplyDeleteAB12
ABC123
ABCD1234
Write a python Program to print :-
ReplyDelete1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
for out in range(1,7):
Deletefor inn in range(1,out):
print(str(inn%2)+" ",end="")
print()
ABCBA
ReplyDeleteAB BA
A A
D
ReplyDeleteCD
BCD
ABCD
BCD
CD
D
1 2 3 4 5
ReplyDelete2 3 4 5
3 4 5
4 5
5
print
ReplyDelete1
2 A 2
3 B B B 3
4 C C C C C 4
*******
ReplyDeleteb*****b
bb***bb
bbb*bbb
How to print?
How to print
ReplyDelete1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
in any language
how to print?
ReplyDelete4444
4333
4322
4321
(It was asked in zoho interview)
import java.util.Scanner;
ReplyDeletepublic class Main{
public static void main(String [] args){
Scanner scan=new Scanner(System.in);
System.out.println("Enter the number of rows:=");
int n=scan.nextInt();
for(int i=n; i>=1; i--)
{
for(int j=n; j>=1; j--)
{
if(j>i)
System.out.print(j);
else
System.out.print(i);
}
System.out.println();
}
}
}
A
ReplyDelete11
BBB
2222
CCCCC
how to print this
How to print for n=5
ReplyDelete* * * * *
. . . . *
* * * . *
* . . .*
* * * * *
*
ReplyDelete* *
* *
* * *
* * *
please any one give me this answer
Please do not Enter any spam link in the comment box