Pattern 30 : C program to print the forward slash star pattern using for loops
Print Forward-slash star pattern program:
Write a C Program to print forward slash star pattern on the console. The program should take input from the user. Which is the number of rows.
Here are the sample input and expected output of the program.
Example 1:
Enter Number : 5
*
*
*
*
*
*
*
*
*
Example 2:
1 2 3 4 5 6 7 8 9 |
Enter Number : 8 * * * * * * * * |
Example 3:
1 2 3 4 |
Enter Number : 3 * * * |
Also Read:
Forward slash pattern Program :
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 |
#include<stdio.h> int main() { int i,j,n; // Accept user input and save it variable 'n' printf("Enter Number : "); scanf("%d",&n); // Number of rows. Loop from 1 to 'n' for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(j <= (n+1-i)) { if( j == (n+1-i) ) printf("* "); else printf(" "); } } printf("\n"); } return 0; } |
Output :
Forward Slash star pattern output |
Note : If you want to print backslash, Here is the example program CLICK HERE.
Similar Star pattern programs :
- Basic star pattern program (The square pattern with stars).
- Triangle star pattern program.
- Triangle star pattern program with Spaces.
- Pyramid star pattern.
- Reverse Pyramid program.
- Diamond Star pattern program.
- star pattern program.
- K-Star pattern program.
- Empty Rhombus program.
- X-Star pattern program
- More Star Patterns
Similar Number Patterns:
- Basic Number Pattern program.
- Triangle Number pattern using for loops.
- Number Pattern 3.
- C Program to print below pattern
5 4 3 2 15 4 3 25 4 35 45
I want double forward slash program in python.