JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Pattern : Difficult Excises in c language in hindi , pattern examples in c programs in computer programming

pattern examples in c programs in computer programming , Pattern : Difficult Excises in c language in hindi :-
इस article मे , पैटर्न के मुश्किल उदाहरण को देखेगे|अगर आन्पे हमारे पैटर्न के पहले वाले article को नहीं पढ़ा तो इस article की Excise को solve’ करने से पहले उन article को जरुर पढ़ा ले |
उदहारण -1 :
Write a program to print below pattern.
input: 2 4 5 6 7 8
pattern :
245678
45678
5678
678
78
8Explanation
1.सबसे पहले यूजर से pattern के लिए digits  को input करा लेते है | जिसे array मे insert करा लेते है |
2.उसके बाद count () function से array की length को calculate करते है जिसे length variable मे assign करते है |
3.Loop चलाया जाता है जिसमे i को 1 से initial किया जाता है|
array के element को print करा लेते है |
4. loop  तब तक चलेगा जब तक i की value  length तक नहीं होती है |Source code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j ;
int a[20];
printf(“Enter digits”);
for()
for(i=0;i<20;i++)
{
scanf(“%d”,&a[i]);
}
int length = count(a);
for(i=0;i<length;i++)
{
for(j=i;j<length;j++)
{
printf(“%d”,a[j]);
}
printf(“\n”);
}
getch();
}int count(int c[ ])
{
int k;
int count =0;
for(k=0;k<20;k++)
{
if(c[k]==’ ‘)
{
return (count);
}
else
{
count++;
}
}
return (count) ;
}

आउटपुट होगा :
Enter digits 2 4 5 6 7 8
245678
45678
5678
678
78
8

उदहारण -2 :
Write a program to print below pattern.
Enter Number : 23456
23456
3456
456
56
6
Explanation
1. सबसे पहले , number को input करते है जिसे number variable मे assign कर देते है |
2. for loop चलाया जाता है :-
number की last डिजिट को eliminate कर देते है |
3. loop तब तक चलाया जाता है जबतक की number की value ‘0’ नहीं हो जाती है |

Source code
#include<stdio.h>
#include<conio.h>
void main()
{
int number ;
printf(“Enter Number”);
scanf(“%d”,&number );
for( n=number ; n!=0 ; number = number /10 )
{
printf(“%d\n”,n);
}
getch()
}आउटपुट होगा :
Enter Number 123345
123345
12334
1233
123
12
1

उदहारण -3 :
Write a program to print below pattern.
1
3    2
4    5   6
10  9   8   7
11 12 13 14 15

Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है|

 

अगर i की value सम होती है तब k की value , k+1 होगी |अन्यथा k+i होगी
inner loop मे , k की value print होगी |
अगर i की value सम होती तब k की value मे increment होगा अन्यथा decreament होगा |
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);
for(i=1;i<=r;i++)
{
if((i%2)==0)
{
k=k+1;
}
else
{
k-=k+i;
}
for(j=1;j<=i,j++)
{
printf(“%d”, k);

if((i%2)==0)
{
k=k++;
}
else
{
k-=k–;
}

}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
Enter Column Number 4
1
3    2
4    5   6
10  9   8   7
उदहारण -4 :
Write a program to print below pattern.
1

22
333
4444
33333
222222
11111111

Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है|
अगर i की value , number of row /2 से छोटी होती है तब inner loop मे , i+1 की value print होती है
अन्यथा n-i+1 की value print होती है |
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);
for(i=1;i<=r;i++)
{
if(i<=r/2)
{
for(j=1;j<=i,j++)
{
printf(“%d”, i+1);
}
}
else
{
for(j=0;j<=i;j++)
{
printf(“%d , r-i+1);
}
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 7
Enter Column Number 7
1
22
333
4444
33333
222222
11111111
उदहारण -5 :
Write a program to print below pattern.
1

2  7
3  8  12
4  9  13  16
5 10 14  17  19
6 11 15  18  20 21

Explanation
1.सबसे पहले यूजर से row और column की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है | इसके अलावा , दूसरा variable ‘k’ को declare करते है |इसके अलावा , एक और variable ‘num’ को भी declare करते है |
3.Loop 1 चलाया जाता है जिसमे i को 1 से initial किया जाता है| और k की value को ‘i’ से initial करते है |
num की value r-1 से initial होती है |
inner loop मे , k की value print होती है |और ककी value मे value + num से increment होगा |
और num मे ‘1’ से decrement हो जायेगा |
inner loop तब तक चलेगा जब तक j की value i के सामान नहीं हो जाती है |
4. loop 1 तब तक चलेगा जब तक i की वाले row तक नहीं होती है |Source code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,num;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
printf(“Enter Column Number “);
scnaf(“%d”,&c);
for(i=1;i<=r;i++)
{
num=r-1;
k=i;
for(j=1;j<=i;j++)
{
printf(“%d”,k);
k=k+num;
num–;
}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 6
Enter Column Number 6
1
2  7
3  8  12
4  9  13  16
5 10 14  17  19
6 11 15  18  20 21
उदहारण -6 :
Write a program to print below pattern.
2
242
24642
2468642Explanation
1.सबसे पहले यूजर से row की number को input करा लेते है |
2.फिर उसके बाद दो variable i और j को declare कर लेते है |
3.दो inner loop चलाया जाता है |
पहले inner loop मे , j की value ‘2’ से initial करते है | और ‘2’ से increment करते है क्योकि सम number print करना है |इस ‘j’ की value को print करा लेते है |ये loop tan तक चलता है जब की j की value i*2 नहीं हो जाती है |इस inner loop से निन्म पैटर्न print होता है |
2
24
246
2468

दुसरे inner loop मे , j को (i-1)*2 से initial करते है |और ‘2’ से decrements होता है |ये loop तब तक चालत है जब तक j की value ‘2’ नहीं हो जाती है |इअमे भी ‘j’ की value print होती है |

Source code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,num;
int c,r;
printf(“Enter Row Number”);
scnaf(“%d”,&r);
for(i=1;i<=r;i++)
{
for(j=2;j<=i*2;i=i+2)
{
printf(“%d”,j);
}
for(j=(i-1)*2;j>=2;j=j-2)
{
printf(“%d”,j);
}}
printf(“\n”);
}
getch();
}
आउटपुट होगा :
Enter Row Number 4
2
242
24642
2468642
Sbistudy

Recent Posts

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

4 weeks ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

4 weeks ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

4 weeks ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

4 weeks ago

चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi

chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…

1 month ago

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

1 month 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