In this tutorial you will learn about the C Program to print exponentially Increasing Star Pattern and its application with practical example.
C Program to print exponentially Increasing Star Pattern
In this tutorial, we will learn to create a C program that will print an exponentially Increasing Star Pattern using C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- For loop in C Programming.
Program to print exponentially Increasing Star Pattern:-
In this program, we will learn to print exponentially Increasing Star Pattern with the help of c programming. First, we will take the input number of rows from the user. Then we will generate the series using the nested for loop to generate the series. Now we will print the series from the child loop using the print function.
1 2 3 4 5 6 7 8 9 10 11 |
Step 1: Start the program. Step 2: Declaring the required variables. Step 3: Taking the input number of rows. Step 4: Generating the pattern using the loops. Step 5: Printing the pattern using the print function. Step 6: End the program. |
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* C Program to Print Exponentially Increasing Star Pattern */ #include <stdio.h> #include <math.h> int main() { //declaring the required variables for the program int rw, i, j; //i = it will hold the integr value //j = it will hold the integr value //Taking the input number of rows. printf("Please Enter the Number of Rows: "); scanf("%d", &rw); //Generating the exponential series. printf("\nPrinting Exponentially Increasing Star Pattern \n"); for ( i = 0 ; i <= rw; i++ ) { for ( j = 1 ; j <= pow(2, i); j++ ) { //Printing the series. printf("* "); } printf("\n"); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- i = it will hold the integer value to control the parent for loop.
- j = it will hold the integer value to control the child for loop.
- rw = it will hold the integer value for the number of rows of pattern.
Taking the input rows and Initializing the first parent for loop size and number of rows.
Generating the series.
Printing the exponential series.