Pattern 11: C Program to print Shallow Rhombus Star Pattern
Shallow Rhombus Star Pattern Introduction:
Write a C Program to print the Shallow Rhombus Star Pattern. We are going to use for loops to create the pattern.
The program accepts input number from the user, Depending upon the user input it will display the shallow Rhombus ( Diamond) Pattern according to specified number size.
Here is an example output, When the input value is 5.
Expected Output:
1 2 3 4 5 6 7 8 9 10 |
Enter the value for n : 5 ********** **** **** *** *** ** ** * * ** ** *** *** **** **** ********** |
Note: This is one the Series of pattern programs in C.
Shallow Rhombus Star Pattern Program in C:
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include<stdio.h> int main() { int i, j, k, n; printf("Enter the value for n : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=(n+1)-i;j++) { printf("*"); } for(k=1;k<i;k++) { printf(" "); // two spaces } for(j=1;j<=(n+1)-i;j++) { printf("*"); } printf("\n"); } for(i=2;i<=n;i++) { for(j=1;j<=i;j++) { printf("*"); } for(k=1;k<=n-i;k++) { printf(" "); // two spaces } for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } return 0; } |
Program Output:
We are using the GCC compiler to compile and Run the programs.
Please learn more about compelling and running program in Linux at following article – Hello World Program in C language – SillyCodes
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.
More C programs:
- Program to calculate Maximum of three numbers.
- What are Prime Number and C program to Check given number is Prime or Not
- Check given Number is Prime or not Using Square Root(sqrt) Function.(Efficient way)
- C Program to generate prime numbers between two numbers
- C Program to generate first N prime numbers.
- C program to Calculate percentage of student.
- C Program to check given year is the leap or not.
- C Program to convert Temperature.
- C program to understand type conversation.
- Finding Largest of two numbers using the conditional operator in C.
- C program to calculate the simple Interest,
- C program to understand Size of Operator.
- 200+ C Programs.
C Tutorials with simple Examples:
- Arithmetic Operators with Examples.
- Arithmetic operators priority and it’s Associativity.
- Modulus Operator and Hidden Concepts of Modulus Operator.
- Precedence Table or Operators Priority Table.
- Assignment Operator, Usage, Examples
- Increment Operator and Different types of Increment operators Usage with Examples.
- Decrement Operator and Different types of Decrement operators with Examples.
- Logical or Boolean Operators.