top of page

Looping Statement:

  • Writer: Siddharth Sharma
    Siddharth Sharma
  • Oct 7, 2025
  • 2 min read

Loops in C एक बहुत important concept है, जिससे हम किसी block of code को बार-बार चला सकते हैं जब तक कोई particular condition satisfy न हो जाए। C language में तीन main प्रकार के loops होते हैं: for loop, while loop, और do-while loop.


Loops का Introduction

Loop programming में repeated tasks करने के लिए use होता है, जैसे arrays की values print करना, calculate करना, या patterns generate करना.


Types of Loops in C

Loop Type

हिंदी में explanation (उदाहरण सहित)

Use case

for loop

जब iterations की गिनती पहले से पता हो।


उदाहरण –


for(int i=0; i<5; i++) { printf("%d", i); }

Fixed बार code repeat करना, जैसे table print करना

while loop

जब condition satisfy होने तक code repeat करना हो।


उदाहरण –


int i=1; while(i<=5) { printf("%d",i); i++; }

Unknown iterations, जैसे input मिलते रहना

do-while loop

कम से कम एक बार code जरूर execute होगा।


उदाहरण –


int i=1; do { printf("%d",i); i++; } while(i<=5);

Menu-driven या कम से कम एक बार logic run ज़रूरी हो

हर loop के तीन basic parts होते हैं: initialization, condition, और update statement.


Loop Control Statements

C में कुछ अन्य statements भी होते हैं, जैसे break, continue, goto, जिनसे loop को control किया जा सकता है (जैसे किसी condition पर loop बीच में ही बंद करना).


Important Points

  • for और while दोनों entry-controlled loops हैं, यानी पहली बार condition check होती है, फिर body execute होती है।

  • do-while एकमात्र exit-controlled loop है, यानी loop body पहले चलेगी फिर condition check होगी.

  • Loops के through code reusability बढ़ती है और redundancy कम होती है.

इस तरह, C language में loops का use program को efficient और compact बनाता है.

 
 
 

Comments


bottom of page