Lesson 2 of 24

Variables, auto மற்றும் stringVariables, auto and string

8 min 20 XP

C++-ல் bool (true/false) மற்றும் string (text) types உள்ளன; C-ன் char array தொல்லை இல்லை. auto மூலம் compiler தானாக type-ஐக் கண்டுபிடிக்கும்.

C++ adds bool (true/false) and string (text), so no more C char-array headaches. With auto the compiler works out the type for you.

Example: edit me and press Run

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

bool இயல்பாக 1/0 என்று print ஆகும்; boolalpha போட்டால் true/false. தசம இடங்களுக்கு <iomanip>-ல் fixed << setprecision(2).

A bool prints as 1/0 by default; boolalpha prints true/false. For decimal places use fixed << setprecision(2) from <iomanip>.

Challenge

+20 XP

course என்ற string-ல் "C++", hours என்ற int-ல் 40 சேமித்து இப்படி print செய்யுங்கள்: Course: C++ Hours: 40

Store "C++" in a string course and 40 in an int hours, then print: Course: C++ Hours: 40

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