About Lesson
- int: Used for storing integer values (whole numbers) such as 1, -5, 1000.
- float: Represents single-precision floating-point numbers, typically used for decimal values with limited precision.
- double: Represents double-precision floating-point numbers, offering higher precision than float.
- char: Used for storing single characters, enclosed in single quotes (”).
- bool: Represents Boolean values, which can be either
true
orfalse
.
Here’s how you declare variables using these data types:
int age = 25;
float weight = 65.5;
double pi = 3.14159;
char grade = ‘A’;
bool isPassed = true;
Join the conversation