Module 4: Tokens and FundamentalsBeginner45 min read
Data Types, Type Modifiers, sizeof, Casting & auto/decltype
Explore fundamental C++ data types, signed/unsigned/short/long modifiers, sizeof operator, implicit/explicit casting, auto, and decltype.
Key Takeaways & Core Concepts
- Explore fundamental C++ data types, signed/unsigned/short/long modifiers, sizeof operator, implicit/explicit casting, auto, and decltype.
- Practice writing and running standard examples.
- Apply best practices and debugging techniques.
Data Types, Type Modifiers, sizeof, Casting & auto/decltype
0
1. static_cast, sizeof, auto & decltype
1#include <iostream>
2
3int main() {
4 int a = 7, b = 2;
5 double res = static_cast<double>(a) / b;
6 auto pi = 3.14159;
7 decltype(a) copyA = 50;
8 std::cout << "res=" << res << ", sizeof(long long)=" << sizeof(long long) << ", copyA=" << copyA << "\n";
9 return 0;
10}
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
10 lines
Note: `static_cast<double>(a)` avoids integer truncation.
Practice & AssessmentC++ Programming Tutorial
Test Your Understanding
Reinforce core concepts with interactive multiple-choice questions, live coding challenges, and top technical interview questions.
Your Current Score
0 / 0 correct(0 attempted)