Page Contents
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
Most Asked Rectangle Pattern Program In C
Below are the various examples of Rectangle patterns that are made using the combination of stars. This Rectangle pattern includes Solid and hollow Rectangle. And the program to print that Rectangle 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 Solid Rectangle using star(*) in C
#include<stdio.h>
#include<conio.h>
void main(){
int i, j, rows, columns;
printf("This is Rectangle program\n");
printf("Enter number of rows: ");
scanf("%d", &rows);
printf("Enter number of columns: ");
scanf("%d", &columns);
for(i=1; i<=rows; i++)
{
for(j=1; j<=columns; j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output
2). Program to print hollow Rectangle using star(*) in C
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, rows, columns;
printf("Hollow Reactangle Program\n");
printf("Enter number of rows: ");
scanf("%d", &rows);
printf("Enter number of columns: ");
scanf("%d", &columns);
for(i=1; i<=rows; i++)
{
for(j=1; j<=columns; j++)
{
if(i==1 || i==rows || j==1 || j==columns)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
getch();
}
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