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 ಬಗ್ಗೆ ಕೇಳುತ್ತಾರೆ!

Challenge

+20 XP

int variable marks ನಲ್ಲಿ 87 ಮತ್ತು double variable percent ನಲ್ಲಿ 87.5 ಇಟ್ಟು print ಮಾಡಿ: Marks: 87 Percent: 87.50

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