Lesson 3 of 23

scanf() மூலம் InputReading Input with scanf()

8 min 20 XP

scanf() user-இடமிருந்து மதிப்புகளைப் படிக்கும். Variable பெயருக்கு முன் & (address) போட வேண்டும், இதனால் scanf அந்த variable-ல் மதிப்பை எழுத முடியும். double படிக்க %lf பயன்படுத்துங்கள்.

scanf() reads values from the user. Put & (address-of) before the variable name so scanf can write into it. Use %lf to read a double.

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 வரை) படிக்கும்.

Reading a string (char array) needs no &, because an array's name is already an address. %s reads only one word, up to a space.

Challenge

+20 XP

ஒரு வட்டத்தின் ஆரத்தை (radius, double) படித்து அதன் பரப்பை 2 தசம இடங்களுடன் print செய்யுங்கள். PI = 3.14159 பயன்படுத்துங்கள். Input: 2 → Output: 12.57

Read the radius of a circle (a double) and print its area with 2 decimal places. Use PI = 3.14159. Input: 2 → Output: 12.57

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