JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Triangle Pattern – Part 2 in c language in hindi , Triangle Pattern examples in c programming in hindi

Triangle Pattern examples in c programming in hindi , Triangle Pattern – Part 2 in c language in hindi :-
इससे पहले के article मे , हमने triangle पैटर्न के 10 उदाहरण को पढ़ा |अब इस article मे triangle पैटर्न के मुश्किल पैटर्न को पढ़गे |
उदहारण -1 :
Write a program to print below pattern.
1
00
111
0000
11111
Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है|\
अगर i की value सम होती है तब
inner loop मे , ‘0’ को print किया जाता है |
और अगर i की value विषम होती है तब |
inner loop मे ,’1′ को print किया जाता है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
if((i%2)==0)
{
for(j=1;j<=i,j++)
{
printf(“0”);
}
}
else
{
for(j=1;j<=i,j++)
{
printf(“1”);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
1
00
111
0000
उदहारण -2 :
Write a program to print below pattern.
1
11
101
1001
11111
Explanation
जब इस पैटर्न को observe किया जाता है तब पता चलता है :-
first और last row के सभी element ‘1’ है |
और first और last column के सभी element ‘1’ है |
और बाकि position के लिए ‘0’ होगी |
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है|
inner loop 2 मे ,
जब (i==1)||(i==r)||(j==1)||(j==c) की condition true होगी तब ‘1’ print होगा
अन्यथा ‘0’ print होगा |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
for(j=1;j<=i,j++)
{
if((i==1)||(i==r)||(j==1)||(j==c) )
{
printf(“1”);
}
else
{
printf(“0”);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
1
11
101
1111
उदहारण -3 :
Write a program to print below pattern.
0
11
000
1111
00000
Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है |
अगर i की value सम होती है तब  inner loop मे , ‘1’ को print किया जाता है |
और अगर i की value विषम होती है तब inner loop मे ,’0′ को print किया जाता है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
if((i%2)==0)
{
for(j=1;j<=i,j++)
{
printf(“1”);
}
}
else
{
for(j=1;j<=i,j++)
{
printf(“0”);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
0
11
000
1111
उदहारण -4 :
Write a program to print below pattern.
1
123
12345
1234567
Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है |
inner loop मे , j की value ‘1’ से initial करते है |
body मे , ‘j’ की value को print करते है |
inner loop तब तक चलेगा जब तक j की value i*2-1 से कम या सामान नहीं हो जाती है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
for(j=1;j<=(2*i-1);j++)
{
printf(“%d”,j);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
1
123
12345
1234567
उदहारण -5 :
Write a program to print below pattern.
1
24
135
2468
13579
Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है | इसके अलावा variable ‘v ‘ को भी declare करेगे |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है |
अगर ‘i’ की value even है तब ‘v’ की value ‘1’ से initial होगी |अन्यथा ‘v’ की value 2 से initial होगी |फिर inner loop perform होगा
inner loop मे , j की value ‘1’ से initial करते है |
body मे , ‘j’ की value को print करते है | और v की value ‘2’ से increment होगी |
inner loop तब तक चलेगा जब तक j की value i से कम या सामान नहीं हो जाती है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
int v;
for(i=1;i<=r;i++)
{
if( v %2==0)
{
v=2;
}
else
{
v=1;
}
for(j=1;j<=i;j++)
{
printf(“%d”,v);
v=v+2;
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 5
Enter Column Number 5
1
24
135
2468
13579
उदहारण -6 :
Write a program to print below pattern.
1
      123
  12345
1234567
Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है | इस loop मे दो inner loop चलेगे|
पहले inner loop मे , space को print किया जाता है |
inner loop मे , j की value ‘1’ से initial करते है |
body मे , ‘j’ की value को print करते है |
inner loop तब तक चलेगा जब तक j की value i*2-1 से कम या सामान नहीं हो जाती है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
for(i=1;i<(r-i)*2;i++)
{
printf(” “);
}
for(j=1;j<=(2*i-1);j++)
{
printf(“%d”,j);
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
          1
      123
  12345
1234567
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