Lesson 2 of 23
Variables மற்றும் Format SpecifiersVariables and Format Specifiers
9 min 20 XP
C-ல் variable-ன் type-ஐ முதலில் சொல்ல வேண்டும்: int (முழு எண்), float / double (தசம எண்), char (ஒரு எழுத்து). printf-ல் மதிப்பைக் காட்ட format specifier பயன்படுத்துகிறோம்: int-க்கு %d, double-க்கு %f அல்லது %lf, char-க்கு %c.
In C you declare a variable's type first: int (whole number), float/double (decimal), char (one character). To print values, printf uses format specifiers: %d for int, %f for double, %c for char.
Example: edit me and press Run
Press Run to see the result here.%.2f இரண்டு தசம இடங்களுடன் காட்டும். sizeof() ஒரு type எத்தனை bytes இடம் எடுக்கிறது என்று சொல்லும். const போட்டால் மதிப்பை மாற்ற முடியாது.
%.2f prints two decimal places. sizeof() tells you how many bytes a type uses. A const variable can't be changed.
Example: edit me and press Run
Press Run to see the result here.தவறான specifier (int-க்கு %f) பயன்படுத்தினால் விசித்திரமான மதிப்புகள் வரும். Interview-ல் format specifiers பற்றி கேட்பார்கள்!
Using the wrong specifier (like %f for an int) prints garbage. Interviewers do ask about format specifiers!