JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Looping in c language in hindi , loops , while , do – while loop , for looping लूप c भाषा में

लूप c भाषा में Looping in c language in hindi , loops , while , do – while loop , for looping :-
इससे पहले goto statement से किसी प्रोग्राम segment को बार बार repeat कर सकते है |लेकिन इसका structure बहुत complex होने पर प्रोग्रम्म की complexity मो बढ़ा देता है |C LANGUAGE मे ,goto statement  के अलावा ,LOOPING की सुविधा भी देता है | LOOPING दो तरह की होती है :-
1.ENTRY CONTROL LOOP:
इस प्रकार मे, control statement looping के शुरुवात मे होती है |अगर condition true नहीं होती है तब LOOP का block execute नहीं होता है |
2.EXIT CONTROL LOOP:
इस प्रकार मे, control statement execute block के बाद होता है | अगर condition true नहीं होती है तब LOOP का block execute एक बार होता है |
किसी भी looping मे control statement बहुत carefully बनाना चाहिए |क्योकि loop का control पूरी तरह condition पर निर्भर करता है |loop मे ,चार प्रकार के operations होते है :-
1.Control variable को set करना |
2.Loop statement को execute करना |
3.Condition को टेस्ट करना |
4.Condition variable को increment करना है |
C language मे तीन looping होती है :-

1. while loop:

While loop entry controlled loop है |इसमें test condition loop के start मे होती है |अगर ये test condition true होती है तब block execute होता है फिर control variable मे increment होता है और condition फिर check होती है |
अगर condition false हो जाती है तब loop block execute नहीं होता है |
इसका syntax है :-
while(condition)
{

 

block statement ;

 

control variable increment;
}
उदहारण :
#include<conio.h>
#include<stdio.h>
void main ()
{

 

int a,mul;

 

int i =1;
printf(“Enter your digit”);
scanf(“%d”,&a);
whille (i<=10)
{

 

mul=a*i;

 

printf(“%d”,mul);
i++;
}
}
इस उदहारण मे , प्रोग्रामर table print हो रहा है | जब तक i की value 10 नहीं हो जाएगी तब तक block statement execute होगा |
आउटपुट होगा :
Enter your digit 2
2 4 6 8 10 12 14 16 18 20

2. do – while loop:

ये loop exit control loop है |इसमें execute body condition check होने से पहले execute होती है |इसका मतलब है loop body एक बार तो execute तो होगी |इसका syntax है :-
do
{
statements;
control variable increment;
}
while(condition);
इसमें body execute होने के बाद , control variable में increment होता है |फिर condition check होती है |अगर condition true होती है तब loop body फिर से execute होती है |
उदाहरण के लिए :
#include<conio.h>
#include<stdio.h>
void main ()
{

 

int a,mul;

 

int i =1;
printf(“Enter your digit”);
scanf(“%d”,&a);
do
{

 

mul=a*i;

 

printf(“%d”,mul);
i++;
}
whille (i<=10);
}
इस उदाहर मे भी table print होगा लेकिन इसमें एक बार printf statement execute हो जायेगे |बाद initialing और condition check होगा |
आउटपुट होगा :
Enter your digit 3
3 6 9 12 15 18 21 24 27 30
उदहारण -2:
#include<conio.h>
#include<stdio.h>
void main ()
{
int sum,a,b ;
sum=3;
printf(“Enter your digit”);
scanf(“%d %d”,&a,&b);
do
{
sum=a+b;
printf(“Your Sum = %d”,sum);
a=a+1;
b=b+2;
}
while((sum/2)==0);
}
इस प्रोग्राम मे sum की value 3 है ,फिर भी a और b का addition एक बार perform होगा |फिर sum/2==0 check होगा |और condition सही होने पर , block execute होगा |
आउटपुट होगा :
Enter your digit 22 12
Your Sum = 34
Your Sum = 37
अब condition true नहीं होने पर , loop block execute नहीं होगा |

3. for looping:

for loop entry controlled loop है | while और do-while loop का syntax complex होता है लेकिन for loop के syntax सरल और आसानी से समजा सकता है|इसका syntax है :-\
for(initial ; condition ;  increment )
{
statements;
}
initial : control variable को initial  करना |
condition : इसमें control expression को check करना |
increment : इसमें control variable का increment करना |
उदहारण के लिए :
#include<conio.h>
#include<stdio.h>
void main ()
{

 

int a,mul,i;

 

printf(“Enter your digit”);
scanf(“%d”,&a);
for(i=1;i<=10;i++)
{
mul=a*i;
printf(“%d”,mul);
}
}
इस उदहारण मे भी , table print हो रहा है | जब तक i की value 10 नहीं हो जाएगी तब तक block statement execute होगा |
आउटपुट होगा :
Enter your digit 2
2 4 6 8 10 12 14 16 18 20
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