-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path5datatypes.cpp
29 lines (22 loc) · 1001 Bytes
/
5datatypes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// As explained in the 3variables program , a variable in C++ must be a specified data type:
// Can see output of below using cut<<variablename;
#include <iostream>
using namespace std;
int main()
{
int myNum = 5; // Integer (whole number)
float myFloatNum = 5.99; // Floating point number
double myDoubleNum = 9.98; // Floating point number
char myLetter = 'D'; // Character
bool myBoolean = true; // Boolean
string myText = "Hello"; // String
return 0;
}
/*
Data Type Size Description
int 4 bytes Stores whole numbers, without decimals
float 4 bytes Stores fractional numbers, containing one or more decimals. Sufficient for storing 7 decimal digits
double 8 bytes Stores fractional numbers, containing one or more decimals. Sufficient for storing 15 decimal digits
boolean 1 byte Stores true or false values
char 1 byte Stores a single character/letter/number, or ASCII values
*/