C programming में कमेंट्स का क्या use है? और comments को अपने code में कैसे use कर सकते हैं?

C programming में comments का क्या use है और comments को अपने code में कैसे use कर सकते हैं
C programming में comments का क्या use है और comments को अपने code में कैसे use कर सकते हैं

Last tutorial में हमने C programming में main() function का क्या use है? और C programs में main function defined कैसे करते हैं करना सीखा था. इस tutorial में हम comments के बारे में पढ़ेंगे और समझेंगे की C programming में comments का क्या use है और comments को कैसे हम अपने code में use कर सकते हैं.

इसके अलावा हम comment के types का syntax और उनका practical example भी देखेंगे. आइये सबसे पहले समझते हैं की comments की जरूरत क्या है.

जब हम programming सीखते हैं तो हमारा program code जिसे हम source code भी कहते है बहुत छोटा होता है यानी उसमे ज्यादा statements (lines of code) नहीं होते हैं.

लेकिन जब हम real life में programs बनाते हैं तो उनमें हजारों lines का code होता है और इस code में हमें या किसी और programmer को future में कुछ changes भी करने होते हैं.

अब इसमें problem ये आती है की code को बहुत समय बाद देखने पर कुछ चीजें (lines of code) समझ नहीं आती है या मैं कहूँ की समझने में time लगता है.

इसके अलावा ऐसा भी हो सकता है की आपके source code में कोई और programmer changes करें तो उसे आपके code को समझने में बहुत ज्यादा time लगे.

(ads)

C Programming में इस problem से बचने के लिए हम अपने source code के बीच-बीच में description text notes का use करते हैं जिन्हें हम comments कहते हैं.

See also  Windows में Python Programs को Run कैसे करते है? - How to Run Python Programs in Windows in Hindi?

Comments की वजह से programmers को ये याद रहता है या मैं कहूँ की समझने में आसानी होती है की कुछ specific lines of code उसने किस काम के लिए लिखा था या ये lines of code का logic क्या था.

इससे आपका source code की readability बढ़ जाती है और comments का use करना good programming practice भी माना जाता है.

Comments programmers के लिए use होते हैं compilers के लिए नहीं यानी C Compiler के लिए comments non-executable statements होते हैं 

इसलिए compiler आपके source code को compile करते वक्त comments को ignore कर देता है और comments आपके program के output में नजर नहीं आते हैं.

C Programming में 2 types के comments का use होता है जिनका syntax और examples में मैंने नीचे दिए हैं. 

Single Line Comment Syntax:

Multi Line Comment Syntax:

Explanation:

Single line comment में double forward slash symbol // का use comment के शुरुआत में होता है.

Multi line comment में comment के शुरुआत में /* और अंत में */ forward slash and asterisk symbol का use होता है.

Single Line Comment Example Program:

    printf("Value of i : %d",i);

Multi Line Comment Example Program:

    printf("Value of i : %d",i);

Output: दोनों program का output same ही आएगा.

Value of i : 20

What’s Next: इस tutorial में हमने C programs में comments का use समझा. Next tutorial में हम समझेंगे की C programming में Keywords and Identifiers क्या होते हैं?

HTN

Hindi Tech News is a trusted technology website dedicated to delivering the latest tech updates in simple and easy Hindi. Our goal is to make technology understandable for everyone — beginners, students, tech lovers, and digital learners.

Related Articles

Back to top button