Page Contents
- 1 Diamond Pattern Program In C: 5+ types of most asked
- 1.1 And below C concepts are used to print that patterns
- 1.2 1). Program to print half pyramid pattern using star(*) in C
- 1.3 2). Program to print left half diamond pattern using star(*) in C
- 1.4 3). Program to print full diamond pattern using star(*) in C
- 1.5 Also Prepare C pattern programs given below
Interview Content
- C Programming Coding Questions
- C Pattern Programming Questions
- C Programming Interview Questions
- Java Programming Coding Questions
- Java Pattern Programming Questions
- Java Programming Interview Questions
- Python Programming Coding Questions
- Python Pattern Programming Questions
- Python Programming Interview Questions
- SQL Interview Questions
Diamond Pattern Program In C: 5+ types of most asked
Below are the various examples of diamond patterns that are made using the combination of stars. This diamond pattern includes full diamond, left and right half diamond, etc. And the program to print that diamonds are written in C programming language.
And below C concepts are used to print that patterns
- For Loop
- While Loop
- if..else
1). Program to print half pyramid pattern using star(*) in C
#include<stdio.h>
#include<conio.h>
void main(){
int i,j,k,n;
printf("enter the number of row for half diamond:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=1;k<=i;k++){
printf("*");
}
printf("\n");
}
for(i=n;i>1;i--)
{
for(k=i;k>1;k--){
printf("*");
}
printf("\n");
}
getch();
}
Output
2). Program to print left half diamond pattern using star(*) in C
#include<stdio.h>
#include<conio.h>
void main(){
int i,j,k,n;
printf("enter the number of row for half diamond:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++){
printf(" ");
}
for(k=0;k<=i;k++){
printf("*");
}
printf("\n");
}
for(i=n-1;i>0;i--)
{
for(j=n;j>=i;j--){
printf(" ");
}
for(k=i;k>0;k--){
printf("*");
}
printf("\n");
}
getch();
}
Output
3). Program to print full diamond pattern using star(*) in C
#include<stdio.h>
#include<conio.h>
int main(){
int i,j,k,n;
printf("enter the number of row for full diamond:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++){
printf(" ");
}
for(k=0;k<2*i+1;k++){
printf("*");
}
printf("\n");
}
for(i=n-1;i>0;i--)
{
for(j=n-1;j>=i;j--){
printf(" ");
}
for(k=2*i-1;k>0;k--){
printf("*");
}
printf("\n");
}
return 0;
}
Output
Latest Uploads on Website
- AVL Tree with explanation
- Radix sort algorithm explanation with example
- Quick Sort Algorithm with explanation
- Bubble sorting algorithm with Bubble sort program in C
- Insertion sort algorithm and program in C
- Selection Sort Algorithm and Program in C
- Linear probing technique explanation with example
- Collision in Hashing and Collision resolution technique
- Hashing in data structure with its types
- Binary search tree operations with Program
- Binary search tree in data structure
- Binary search algorithm in data structure with explanation
- linear search in data structure with Algo and Program