JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Pattern – Examples (Part-2) in c language in hindi , पैटर्न के उदाहरण c कंप्यूटर भाषा में हिंदी में

पैटर्न के उदाहरण c कंप्यूटर भाषा में हिंदी में , Pattern – Examples (Part-2) in c language in hindi :-
Pattern – Examples (Part-1 ) मे , हमने related उदाहरण को पढ़ा |अब इस article मे कुछ और पैटर्न क उदहारण  को पढ़गे |
उदाहरण -1
Write a program to make blowing pattern.
इस उदहारण मे , नीचे दिए गये पैटर्न को print करने के लिए code को लिखना है |
00100
00100
11111
00100
00100
Explanation :
इस पैटर्न को बनाने के लिए निन्म लॉजिक का पता लगा न होता :
मिड row और मिड column के सभी elements ‘0’ है और बाकि row और column के सभी element ‘1’ है |
1.सबसे पहले,यूजर से row और column की सख्या को input करा लेते है जिसे ‘r’ और ‘c’ मे assign कर देते है |
2.इसके बाद ‘i’ और ‘j’ को declare करते है जिन्हें looping मे use किया जाता है |
3.looping होती है | इसमें दो loops चलाया जाता है |एक row के लिए और दूसरा column के लिए|
Loop मे , जब i की value ‘row/2’ हो या j की value ‘column/2’ हो तब ‘0’ print होगा अन्यथा ‘1’ print होगा |
3. ये loop तब तक चलेगे जब तक की i की value row के सामान नहीं हो जाती है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,r,c;
printf(“Enter Number of Row :”)
scnaf(“%d”,&r);
printf(“Enter Number of Column :”)
scnaf(“%d”,&c);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if((i%2)==0)&& ((j%2)==0))
{
if((i==(r/2))|| (j==(c/2)))
{
printf(“0”);
}
else
{
printf(“1”);
}
}
else if((i==(r+1)/2) || (i==r/2) || (j==(c+1)/2) || (j==c/2) )
{
printf(“1”);
}
else
{
printf(“0”);
}
getch();
}
आउटपुट होगा :
Enter Number of Row : 5
Enter Number of Column : 5
00100
00100
11111
00100
00100
उदाहरण -2
Write a program to make blowing pattern.
इस उदहारण मे , नीचे दिए गये पैटर्न को print करने के लिए code को लिखना है |
010101
101010
010101
101010
010101
Explanation :
इस पैटर्न को बनाने के लिए निन्म लॉजिक का पता लगाना  होता :
1.सबसे पहले,यूजर से row और column की सख्या को input करा लेते है जिसे ‘r’ और ‘c’ मे assign कर देते है |
2.इसके बाद ‘i’ और ‘j’ को declare करते है जिन्हें looping मे use किया जाता है |
3.looping होती है | इसमें दो loops चलाया जाता है |एक row के लिए और दूसरा column के लिए|
Loop मे , जब i की value , सम होती है तब सबसे पहले ‘1’ print होगा और बाद मे ‘0’ print होगा |
और अगर विसम होती तब सबसे पहले ‘0’ print होगा और बस मे ‘1’ print होगा |
3. ये loop तब तक चलेगे जब तक की i की value row के सामान नहीं हो जाती है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,r,c;
printf(“Enter Number of Row :”)
scnaf(“%d”,&r);
printf(“Enter Number of Column :”)
scnaf(“%d”,&c);
for(i=1:i<=r;i++)
{
if(i %2 ==0 ) {
for(j=1;j<=c;j++)
{
if(j % 2 ==0) {
printf(“1”);
}
else {
printf(“0”);
}
}
else
{
for(j=1;j<=c;j++) {
if(j % 2 != 0)  {
printf(“0”);
}
else  {
printf(“1”);
}
}
}
printf(“\n”);
}
}
getch();
}
आउटपुट होगा :
Enter Number of Row : 5
Enter Number of Column : 5
010101
101010
010101
101010
010101
उदाहरण -3
Write a program to make blowing pattern.
इस उदहारण मे , नीचे दिए गये पैटर्न को print करने के लिए code को लिखना है |
\/\/\
/\/\/
\/\/\
\/\/\
\/\/\
Explanation :
इस पैटर्न को बनाने के लिए निन्म लॉजिक का पता लगाना  होता :
1.सबसे पहले,यूजर से row और column की सख्या को input करा लेते है जिसे ‘r’ और ‘c’ मे assign कर देते है |
2.इसके बाद ‘i’ और ‘j’ को declare करते है जिन्हें looping मे use किया जाता है |
3.looping होती है | इसमें दो loops चलाया जाता है |एक row के लिए और दूसरा column के लिए|
Loop मे , जब i की value , सम होती है तब सबसे पहले ‘\’ print होगा और बाद मे ‘/’ print होगा |
और अगर विसम होती तब सबसे पहले ‘/’ print होगा और बस मे ‘\’ print होगा |
3. ये loop तब तक चलेगे जब तक की i की value row के सामान नहीं हो जाती है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,r,c;
printf(“Enter Number of Row :”)
scnaf(“%d”,&r);
printf(“Enter Number of Column :”)
scnaf(“%d”,&c);
for(i=1:i<=r;i++)
{
if(i %2 ==0 ) {
for(j=1;j<=c;j++)
{
if(j % 2 ==0) {
printf(“\”);
}
else {
printf(“/”);
}
}
else
{
for(j=1;j<=c;j++) {
if(j % 2 != 0)  {
printf(“/”);
}
else  {
printf(“\”);
}
}
}
printf(“\n”);
}
}
getch();
}
आउटपुट होगा :
Enter Number of Row : 5
Enter Number of Column : 5
\/\/\
/\/\/
\/\/\
\/\/\
\/\/\
उदाहरण -4
Write a program to make blowing pattern.
इस उदहारण मे , नीचे दिए गये पैटर्न को print करने के लिए code को लिखना है |
12345
23456
34567
45678
56789
Explanation :
इस पैटर्न को बनाने के लिए निन्म लॉजिक का पता लगाना  होता :
1.सबसे पहले,यूजर से row और column की सख्या को input करा लेते है जिसे ‘r’ और ‘c’ मे assign कर देते है |
2.इसके बाद ‘i’ और ‘j’ को declare करते है जिन्हें looping मे use किया जाता है |
3.looping होती है | इसमें दो loops चलाया जाता है |एक row के लिए और दूसरा column के लिए|
पहले loop मे , नार्मल parameter pass होते है |
लेकिन दुसरे for loop statement मे ,
initial मे row की value से होगी |
और condition तब तक चलेगा जब तक की j की value ‘i+column’ तक चलेगा |
उसके बाद ‘j’ की value print होगी |
3. ये loop तब तक चलेगे जब तक की i की value row के सामान नहीं हो जाती है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,r,c;
printf(“Enter Number of Row :”)
scnaf(“%d”,&r);
printf(“Enter Number of Column :”)
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
for(j=i;j<=c+i;j++)
{
printf(“%d”,j);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Number of Row : 5
Enter Number of Column : 5
12345
23456
34567
45678
56789
उदाहरण -5
Write a program to make blowing pattern.
इस उदहारण मे , नीचे दिए गये पैटर्न को print करने के लिए code को लिखना है |
01110
10001
10001
10001
01110
Explanation :
इस पैटर्न को बनाने के लिए निन्म लॉजिक का पता लगाना  होता :
1.सबसे पहले,यूजर से row और column की सख्या को input करा लेते है जिसे ‘r’ और ‘c’ मे assign कर देते है |
2.इसके बाद ‘i’ और ‘j’ को declare करते है जिन्हें looping मे use किया जाता है |
3.looping होती है | इसमें दो loops चलाया जाता है |एक row के लिए और दूसरा column के लिए|
इसमें दो conditions को check की जाती है :-
3.i- first और last row एव first और last column के सभी element ‘1’ होगे  लेकिन
3.ii- बॉक्स के corner पर ‘0’ print होगा |
उसके बाद ‘j’ की value print होगी |
3. ये loop तब तक चलेगे जब तक की i की value row के सामान नहीं हो जाती है |
Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,r,c;
printf(“Enter Number of Row :”)
scnaf(“%d”,&r);
printf(“Enter Number of Column :”)
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
for(j=i;j<=c+i;j++)
{
if((i==1|| i==r ) && (j==1|| j==c ) )
{
printf(“0”);
}
elseif(i==0|| i==r || j==0 || j==c)
{
printf(“1”);
}
else{
printf(“0”);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Number of Row : 5
Enter Number of Column : 5
01110
10001
10001
10001
01110
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