VOOZH about

URL: https://www.geeksforgeeks.org/dsa/c-programs-print-interesting-patterns/

⇱ Programs to print Interesting Patterns - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Programs to print Interesting Patterns

Last Updated : 2 May, 2025

Program to print the following pattern: 

Examples :

Input : 5
Output:
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *

This program is divided into four parts.


Output
* * * * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * * *

Time Complexity: O(n2)
Auxiliary Space: O(1)

Program to print following pattern: 

Examples :

Input : 5
Output:
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *

This program is divided into four parts. 


Output
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *

Time Complexity: O(n2)
Auxiliary Space: O(1)

Program to print the following pattern:

Examples:

Input : 9 [For Odd number]
Output:
\*******/
*\*****/*
**\***/**
***\*/***
****/****
***/*\***
**/***\**
*/*****\*
/*******\

Input : 8 [For Even number]
Output :
\******/
*\****/*
**\**/**
***\/***
***/\***
**/**\**
*/****\*
/******\

Code implementation to print the given pattern:


Output
\*******/
*\*****/*
**\***/**
***\*/***
****/****
***/*\***
**/***\**
*/*****\*
/*******\

Time Complexity: O(n2)
Auxiliary Space: O(1)

Program to print the following pattern:

Examples  :

Input : 8
Output :
7 6 5 4 3 2 1 0
6 5 4 3 2 1 0
5 4 3 2 1 0
4 3 2 1 0
3 2 1 0
2 1 0
1 0
0

Code implementation to print the given pattern:


Output
7 6 5 4 3 2 1 0 
6 5 4 3 2 1 0 
5 4 3 2 1 0 
4 3 2 1 0 
3 2 1 0 
2 1 0 
1 0 
0 

Time Complexity: O(n2)
Auxiliary Space: O(1)

Program to print the following pattern :

Examples:

Input: 7
Output:
1
8 2
14 9 3
19 15 10 4
23 20 16 11 5
26 24 21 17 12 6
28 27 25 22 18 13 7

Code implementation to print the given pattern:


Output
1 
8 2 
14 9 3 
19 15 10 4 
23 20 16 11 5 
26 24 21 17 12 6 
28 27 25 22 18 13 7 

Time Complexity: O(n2)
Auxiliary Space: O(1)


Comment