Objective: To examine and verify different data types.
Data types are essential in programming, defining the kind of data that can be stored and used within a program.
Primitive data types are the most basic, built-in types provided by programming languages for storing simple values.
Example: int a = 2;
Example: float x = 5.9;
Example: double a = 5.97585858;
Example: char initial = 'A';
Example: bool isStudent = true;
String: Represents a sequence of characters.
Example: string name = "Mason";
-
Begin
-
Include the Necessary Headers
-
Include the header files
<string>
and<iostream>
for string and I/O operations. Use the standard namespace. -
Declare variables of various data types: int, float, char, bool, string, and double.
-
Input and Output Operations
-
For each variable:
- Prompt the user to enter a value.
- Read the input value.
- Output the size of the variable using the
sizeof
operator.
-
End