Lesson 2 of 23

Variables மற்றும் Format Specifiers

9 min 20 XP

C-ல் variable-ன் type-ஐ முதலில் சொல்ல வேண்டும்: int (முழு எண்), float / double (தசம எண்), char (ஒரு எழுத்து). printf-ல் மதிப்பைக் காட்ட format specifier பயன்படுத்துகிறோம்: int-க்கு %d, double-க்கு %f அல்லது %lf, char-க்கு %c.

Example: edit me and press Run

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

%.2f இரண்டு தசம இடங்களுடன் காட்டும். sizeof() ஒரு type எத்தனை bytes இடம் எடுக்கிறது என்று சொல்லும். const போட்டால் மதிப்பை மாற்ற முடியாது.

Example: edit me and press Run

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

தவறான specifier (int-க்கு %f) பயன்படுத்தினால் விசித்திரமான மதிப்புகள் வரும். Interview-ல் format specifiers பற்றி கேட்பார்கள்!

Challenge

+20 XP

marks என்ற int variable-ல் 87, percent என்ற double variable-ல் 87.5 சேமித்து இப்படி print செய்யுங்கள்: Marks: 87 Percent: 87.50

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