![]() |
VOOZH | about |
Here, we will see how to print continuous character patterns using a C program. Below are the examples:
Input: rows = 5
Output:A
B C
D E F
G H I J
K L M N OInput: rows = 3
Output:A
B C
D E F
There are 2 ways to print continuous character patterns in C:
Let's discuss each of these in detail.
Approach 1: Using Character
Below is the C program to print continuous character patterns using character using for loop:
A B C D E F
Approach 2: Converting a given number into a character
Below is the C program to print continuous character patterns by converting numbers into a character:
A B C D E F G H I J K L M N O
Approach 1: Using character
The while loops check the condition until the condition is false. If the condition is true then enter into a loop and execute the statements. Below is the C program to print continuous character patterns using character:
A B C D E F G H I J K L M N O
Time complexity: O(R*R) where R is given no of rows
Auxiliary space: O(1)
Approach 2: Converting a given number into a character
Below is the C program to print a continuous character pattern by converting a given number into a character using a while loop:
A B C D E F G H I J K L M N O
Time complexity: O(n2) where n is given rows
Auxiliary Space: O(n)