JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

C++ : Do-While or While Loop in hindi , what is do while and while loop in c++ language with program example

what is do while and while loop in c++ language with program example , C++ : Do-While or While Loop in hindi :-
इससे पहले के article मे , for loop के बारे मे discuss किया है अब इस article मे while और do-while loop को discuss करते है |
While loop
while loop के syntax मे initial और update statement को नहीं लिखा जाता है | इसमें केवल test condition को लिखा जाता है | इसका syntax होता है :-
while(test condition)
{
body ;
}
इस syntax मे initial को while loop के बहार लिखा जाता है | और update statement को loop की body मे लिखा जाता है |
सबसे test condition को check किया जाता है | अगर test condition true होती है तब  loop की body को execute किया जाता है |
इस loop body मे केवल एक statement होता है तब {} को use करना complusy नहीं होता है | लेकिन एक statement से ज्यादा statements होता है तब {} को use करना चाहिए |
जब इस body execute हो जाती तब loop का control while loop की start मे आ जाता है | फिर से condition check की जाती है | अगर condition true होती है तब loop की body फिर execute हो जाती है |
ये प्रोसेस तब तक चलती है जब तक condition true होती रहती है |
अगर किसी loop को terminate करना होता है तब test condition को इसी तरह से set किया जाता है |
While loop entry level loop है जिसका मतलब है की अगर loop की condition को false होगी तो loop की body एक बार भी execute नहीं होता है |
इसका उदाहरन होता है :
#include<iostream.h>
#include<conio.h>
void main()
{
int mul,number ;
int i = 1;
cout<<“Enter number : “<<endl;
cin>>number;
cout<< “Table of “<<number<<endl;
while(i<=10)
{
mul=number*i;
cout<<number <<“*”<< i <<“=”<< mul<<endl;
i++;
}
getch();
}
इस article मे , while loop से table को print  किया जाता है | इसके लिए :-
सबसे पहले i को 1 से initial किया जाता है | और while loop मे condition i<=10 को check करते है | और loop की body मे i की value को increment किया जाता है | यूजर द्वारा input किया गया value ‘2’ है |
तब i = 1 है तब mul = 2 होगा |
तब i = 2 है तब mul = 4 होगा |
तब i = 3 है तब mul = 6 होगा |
तब i = 4 है तब mul = 8 होगा |
तब i = 5 है तब mul = 10 होगा |
ये loop तब तक चलता है जब तक i की value 10 नहीं हो जाती है |
इसका आउटपुट होगा :-
Enter number : 4
Table of 4
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28
4*8=32
4*9=36
4*10=40Do-While loop
Do while loop के syntax मे initial और update statement को नहीं लिखा जाता है | और Do while loop के statement को body के बाद लिखा जाता है | इसमें केवल test condition को लिखा जाता है | इसका syntax होता है :-
{
body ;
}
do while(test condition)
इस syntax मे initial को do while loop के बहार लिखा जाता है | और update statement को loop की body मे लिखा जाता है |
सबसे पहले loop की body perform होती है फिर loop की condition check की जाती है |
वwhile loop की तरह , अगर  loop body मे केवल एक statement होता है तब {} को use करना complusy नहीं होता है | लेकिन एक statement से ज्यादा statements होता है तब {} को use करना चाहिए |
जब इस body एक बार perform हो जाती तब loop का condition check की जाती है | condition के true होने पर body को perform किया जाता है | फिर से condition को check किया जाता है | ये प्रोसेस तब तक चलती है जब तक condition true होती रहती है |
अगर किसी loop को terminate करना होता है तब test condition को इसी तरह से set किया जाता है |
Do-While loop ending level loop है जिसका मतलब है की loop की body एक बार तो perform होती है | उसके बाद condition को check की जाती है |
इसका उदाहरन होता है :
#include<iostream.h>
#include<conio.h>
void main()
{
int mul,number ;
int i = 1;
cout<<“Enter number : “<<endl;
cin>>number;
cout<< “Table of “<<number<<endl;
{
mul=number * i;
cout<<number <<“*”<< i <<“=”<< mul<<endl;
i++;
}
do while (i<=10);
getch();
}
इस article मे , do-while loop से table को print  किया जाता है | इसके लिए :-
सबसे पहले i को 1 से initial किया जाता है | और loop की body मे  table की first row को print किया जाता है | उसके बाद i की value को increment किया जाता है | फिर condition check की जाती है | अगर यूजर द्वारा input किया गया value ‘2’ है |
तब i = 1 है तब mul = 2 होगा | इसके बाद i की value increment किया जाता है |
तब i = 2 है तब mul = 4 होगा |इसके बाद i की value increment किया जाता है |
तब i = 3 है तब mul = 6 होगा |इसके बाद i की value increment किया जाता है |
तब i = 4 है तब mul = 8 होगा |इसके बाद i की value increment किया जाता है |
तब i = 5 है तब mul = 10 होगा |इसके बाद i की value increment किया जाता है |
ये loop तब तक चलता है जब तक i की value 10 नहीं हो जाती है |
इसका आउटपुट होगा :-
Enter number : 4
Table of 4
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28
4*8=32
4*9=36
4*10=40इस article मे while और do-while loop को discuss किया है अब आगे के article मे while और do-while loop के उदाहरनो को discuss करेगे |
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

16 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

16 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

2 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

2 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months 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