Type casting means converting one data type into another.
int a = 10;
double b = (double)a;
cout << b;
Output: 10
Modern C++ also supports explicit casting:
double result = static_cast<double>(10) / 3;
8. Comments in C++
Comments are used to explain code. The compiler ignores them.
Single-line comment:
// This is a comment
int age = 25;
Multi-line comment:
/*
This is a
multi-line comment
*/
9. Practice Programs
Try writing these programs yourself:
• Print Hello World.
• Store your name and age in variables and print them.
• Take two numbers as input and calculate their sum.
• Calculate the area of a rectangle.
• Convert an integer into a double.
10. Important Things to Remember
• C++ is case-sensitive.
• Every statement generally ends with a semicolon (;).
•
main() is the entry point of a program.• Variables must have a data type.
• Use
cin for input and cout for output.• Curly braces
{} define code blocks.Double Tap ❤️ For Part-2
