Read in Hindi
Read in English

Going forward with this C/C++ programming language tutorial today we will learn to use while loop. This needs a boolean statement. Statement will continue to run repeated times till given boolean expression evaluates to true. Lets look into this by an example given below. Again we will print square of numbers from 1 to 10 using while loop.
#include <stdio.h>

int main() {
int i=1;
int sq;
while(i<=10) {
sq = i*i;
printf("square of %d is %d.\n", i, sq);
i = i+1;
}

scanf("%d", &i);
return 1;
}
In the example given above initial value of i is 1. then boolean expression inside while loop is i<=10 which evaluates to true because i is 1, Hence all statements inside loop will be executed. See that we are increasing value of i inside loop by 1. Again boolean statement will be true because i is 2. Similarly program will continue. When value of i will reach 11, boolean statement will be false and program will go out of while loop. Try to run this program to see the output.

In next topic we will learn to use string and see some interesting examples.
If you like this tutorial, share it with your friends on facebook, orkut, twitter etc.
आज Hindi के इस C/C++ programming language tutorial को आगे बढ़ाते हुए हम while loop का उपयोग करना सीखेंगे. इसमें एक boolean statement दिया जाता है. जब तक उसकी value true आती है तब तक loop के अंदर लिखे statement run होते रहते हैं. जब तक  नीचे दिए गए example से समझते हैं. while loop का उपयोग करके एक बार फिर से 1 से 10 तक कि संख्याओ के square print करेंगे
#include <stdio.h>

int main() {
int i=1;
int sq;
while(i<=10) {
sq = i*i;
printf("square of %d is %d.\n", i, sq);
i = i+1;
}

scanf("%d", &i);
return 1;
}

ऊपर दिए गए program में i की प्रारंभिक  value 1  है. उसके बाद while loop का boolean statement है i<=10 जो कि true  है क्योंकि i की value 1 है, इसलिए loop के अंदर लिखे सारे statement execute हो जायेंगे. ध्यान दें कि हम loop के अंदर i की value 1 बढ़ा रहे हैं. फिर से boolean statement true  हो जायेगा क्योंकि i की  value 2 हो गयी है. इसी तरह आगे बढते रहेंगे. जब i की value 11 हो जायेगी तब boolean statement false हो जाएगा और हम while loop से बाहर आ जायेंगे. इस program को चला कर देखें. यह 1 से 10 तक सभी संख्याओ के square print करेगा.

अगले लेख में हम string का उपयोग करना सीखेंगे और साथ ही उसका use करके कुछ interesting example देखेंगे.
अगर आपको यह लेख पसंद आया हो तो अपने दोस्तों को भी बताएं क्योंकि ये उनके लिए भी उपयोगी सिद्ध हो सकता है !! नीचे दिए गए link के माध्यम से इसे आसानी से facebook twitter और Google Buzz पर भी Share कर सकते हैं.