Loops in C in Hindi – C Loops in Hindi

Loops in C in Hindi – C Loops in Hindi इस Article में हम C Loops के बारे में जानेगे। Loops Programming Language का काफी Important Chapter है। इसलिए इसको ध्यान से पढ़ना है। लेकिन Loops पढ़ने से पहले पिछले Article Decision Making in C in Hindi को अवश्य पढ़ ले। क्युकी इसमें Decision Making (Condition Statement ) का काफी Use है।
Loops in C in Hindi
Loops के द्वारा किसी भी Statement को एक से अधिक (Multiple Times ) Run करा सकते है। जब हमें किसी Program में किसी Code (Statement) को बहुत बार Run कराना होता है, तब Loops का Use किया जाता है। हमें बार – बार Code को लिखना न पड़े इस समस्या को Solve करने के लिए Loops बनाये गए है।
Types of Loops in C in Hindi
C Language में तीन प्रकार के Loops होते है। जिनकी List नीचे है।
- While Loop
- Do-While Loop
- For Loop
- While Loop in C in Hindi
While Loop in C in Hindi
While loop एक simple Loop है। ये तब तक Execute होता रहता है, जब तक Condition false नहीं होती है। और ये तभी Execute होगा जब Condition True होगी।
Syntax of While Loop in Hindi
while(condition) {
Statement;
}
अब इसका Example देखते है।
#include<stdio.h>
int main() {
int x = 1;
while (x<=10) {
printf(“This Loop is:%dn“,x);
x++;
}
return 0;
}
Output
This Loop is:1 This Loop is:2 This Loop is:3 This Loop is:4 This Loop is:5 This Loop is:6 This Loop is:7 This Loop is:8 This Loop is:9 This Loop is:10
1. यहाँ पे देख सकते है। सबसे पहले int x = 1; एक Variable Create किया गया है।
Do While Loop in C in Hindi
Syntax of Do While Loop in Hindi
do { statement; } while (condition);
अब do While loop का Example देखते है।
#include <stdio.h> int main() { int x = 1; do{ printf("Value x:%dn",x); x = x+1; } while(x<=20); return 0; }
Value x:1 Value x:2 Value x:3 Value x:4 Value x:5 Value x:6 Value x:7 Value x:8 Value x:9 Value x:10 Value x:11 Value x:12 Value x:13 Value x:14 Value x:15 Value x:16 Value x:17 Value x:18 Value x:19 Value x:20
इसमें आप देख सकते है उसी तरह से Statement लगा है do loop लगा है। लेकिन while(x<=20); Condition Bottom में लगी हुई है।
For Loop in C in Hindi
Syntax of for Loop in C in Hindi
for (initialization Statement; test Expression; Update Expression) { //code to execute in Loop }
1. Initialization Expression केवल एक बार Execute होता है।
#include <stdio.h>
int main() {
int i;
for (i = 1; i < 11; i++)
{
printf(“%d “, i);
}
return 0;
}
Output
1 2 3 4 5 6 7 8 9 10