Lesson 3 of 23

scanf() से Input पढ़ना

8 min 20 XP

scanf() user से values पढ़ता है। Variable के नाम से पहले & (address-of) लगाएँ ताकि scanf उसमें लिख सके। double पढ़ने के लिए %lf लें।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

String (char array) पढ़ने में & नहीं लगता, क्योंकि array का नाम पहले से ही एक address है। %s सिर्फ़ एक शब्द पढ़ता है, space तक।

Challenge

+20 XP

वृत्त की त्रिज्या (एक double) पढ़ें और उसका क्षेत्रफल 2 दशमलव स्थानों तक print करें। PI = 3.14159 लें। Input: 2 → Output: 12.57

Output Loading C (first time takes a few seconds)
Press Run to see the result here.