Lesson 2 of 23
Variables మరియు Format Specifiers
9 min 20 XP
C లో ముందుగా variable type ను declare చేస్తాం: int (పూర్ణ సంఖ్య), float/double (దశాంశం), char (ఒక అక్షరం). Values ను print చేయడానికి printf format specifiers వాడుతుంది: int కు %d, double కు %f, 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 రెండు దశాంశ స్థానాలతో print చేస్తుంది. sizeof() ఒక type ఎన్ని bytes వాడుతుందో చెబుతుంది. const variable ను మార్చలేరు.
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 వంటిది) వాడితే చెత్త print అవుతుంది. Interviewers నిజంగానే format specifiers గురించి అడుగుతారు!