JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: C Language in hindi

Star Pattern : Examples , Square Pattern , Explanation and source code in c language program in hindi

Explanation and source code in c language program in hindi , Star Pattern : Examples , Square Pattern :-
इससे पहले article मे , number पैटर्न को discuss किया है अब इस article मे , star पैटर्न को discuss करेगे |जो की concept building करता है |प्रोग्रामर को problem के solution को किस तरह से find करना है |और कैसे इसे प्रोग्राम मे ट्रांसलेट करना है |
Square Pattern
write a program to print square pattern.
*****
*****
*****
*****
*****
Explanation
1.सबसे पहले यूजर से row और column के number को input करा लेते है |
2.उसके बाद looping होती है जिसमे दो loops होते है|
3.outer loop मे , ‘i’ की value ‘1’ से initial होती | ये loop तब तक चलते है जब तक इसकी value ‘row’ से छोटी या सामान हो |
4.inner loop मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value ‘column’ से छोटी या सामान हो |
इस loop की body मे , “*” को print करते है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i , j ;
int row , column;
printf(“Enter Row Size”);
scanf(“%d”,&row);
printf(“Enter Colunm Size”);
scanf(“%d”,&column);
for(i=0;i<row;i++)
{
for(j=0;j<colunm;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Size 5
Enter Colunm Size 5
*****
*****
*****
*****
*****
Hollow Pattern
write a program to print hollow pattern.
*****
*      *
*      *
*      *
*****
Explanation
1.सबसे पहले यूजर से row और column के number को input करा लेते है |
2.उसके बाद looping होती है जिसमे दो loops होते है|
3.outer loop मे , ‘i’ की value ‘1’ से initial होती | ये loop तब तक चलते है जब तक इसकी value ‘row’ से छोटी या सामान हो |
4.inner loop मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value ‘column’ से छोटी या सामान हो |
इस loop की body मे , जब i=1 और i=row और j=1 और j=colunm के सामान होती है तब “*” print होगा |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i , j ;
int row , column;
printf(“Enter Row Size”);
scanf(“%d”,&row);
printf(“Enter Colunm Size”);
scanf(“%d”,&column);
for(i=0;i<row;i++)
{
for(j=0;j<colunm;j++)
{
if((i==1)||(i==row)||(j==1)||(j==colunm))
{
printf(“*”);
}
else{
printf(” “);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Size 5
Enter Colunm Size 5
*****
*      *
*      *
*      *
*****
Pattern-3
write a program to print pattern.
********
**  **  **
*  *    *  *
**  **  **
*  *    *  *
********
Explanation
1.सबसे पहले यूजर से row और column के number को input करा लेते है |
2.उसके बाद looping होती है जिसमे दो loops होते है|
3.outer loop मे , ‘i’ की value ‘1’ से initial होती | ये loop तब तक चलते है जब तक इसकी value ‘row’ से छोटी या सामान हो |
4.inner loop मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value ‘column’ से छोटी या सामान हो |
इस loop की body मे , जब i=1 और i=row और j=1 और j=colunm और i=j और j=r-i+1  होती है तब “*” print होगा |
अन्यथा space ” ” print होगा |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i , j ;
int row , column;
printf(“Enter Row Size”);
scanf(“%d”,&row);
printf(“Enter Colunm Size”);
scanf(“%d”,&column);
for(i=0;i<row;i++)
{
for(j=0;j<colunm;j++)
{
if((i==1)||(i==row)||(j==1)||(j==colunm)||(i==j)||(j==(r-i+1)))
{
printf(“*”);
}
else{
printf(” “);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Size 5
Enter Colunm Size 5
*****
**  **
*  *  *
**  **
*****
Pattern-4
write a program to print square pattern.
     ******
   ******
 ******
******
******
Explanation
1.सबसे पहले यूजर से row और column के number को input करा लेते है |
2.उसके बाद looping होती है जिसमे तीन  loops होते है|
3.outer loop मे , ‘i’ की value ‘1’ से initial होती | ये loop तब तक चलते है जब तक इसकी value ‘row’ से छोटी या सामान हो |
4.inner loop 1  मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value
‘row-i’ से छोटी या सामान हो |
इस loop की body मे , space ” ” को print करेगे |
5.inner loop 2  मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value
‘colunm’ से छोटी या सामान हो |
इस loop की body मे , j की value को print करेगे |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i , j ;
int row , column;
printf(“Enter Row Size”);
scanf(“%d”,&row);
printf(“Enter Colunm Size”);
scanf(“%d”,&column);
for(i=1;i<=row;i++)
{
for(j=1;j<row-i;j++)
{
printf(” “);
}
for(j=1;j<colunm;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Size 5
Enter Colunm Size 5
     ******
   ******
 ******
******
******
Pattern-3
write a program to print square pattern.
*****
*****
 *****
   *****
     *****
Explanation
1.सबसे पहले यूजर से row और column के number को input करा लेते है |
2.उसके बाद looping होती है जिसमे तीन  loops होते है|
3.outer loop मे , ‘i’ की value ‘1’ से initial होती | ये loop तब तक चलते है जब तक इसकी value ‘row’ से छोटी या सामान हो |
4.inner loop 1  मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value
‘i’ से छोटी या सामान हो |
इस loop की body मे , space ” ” को print करेगे |
5.inner loop 2  मे , j की value ‘1’ से initial होती है | ये loop तब तक चलता है जब तक इसकी value
‘colunm’ से छोटी या सामान हो |
इस loop की body मे , j की value को print करेगे |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i , j ;
int row , column;
printf(“Enter Row Size”);
scanf(“%d”,&row);
printf(“Enter Colunm Size”);
scanf(“%d”,&column);
for(i=1;i<=row;i++)
{
for(j=1;j<i;j++)
{
printf(” “);
}
for(j=1;j<=colunm;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Size 5
Enter Colunm Size 5
*****
*****
 *****
   *****
     *****
Sbistudy

Recent Posts

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now