A-z
0-9
_
module
Module
MODULE
;
=
aVariable = "String Data Type" anotherVariable = 1.0
string aVariable = "String Data Type"; float anotherVariable = 1.0;
bool
true
false
1
0
#include <iostream> bool boolExample1 = true; bool boolExample2 = false; int main() { std::cout << "boolExample1 -> " << boolExample1 << std::endl; std::cout << "boolExample2 -> " << boolExample2 << std::endl; return 0; }
boolExample1 -> 1 boolExample2 -> 0
char
'
#include <iostream> char charExample1 = 'A'; char charExample2 = 'b'; char charExample3 = 'abc'; int main() { std::cout << "charExample1 -> " << charExample1 << std::endl; std::cout << "charExample2 -> " << charExample2 << std::endl; std::cout << "charExample3 -> " << charExample3 << std::endl; return 0; }
charExample1 -> A charExample2 -> b charExample3 -> c
string
"
#include <iostream> #include <string> std::string strExample1 = "This is with numbers: 1, 2, 3, 4."; std::string strExample2 = "A"; int main() { std::cout << "strExample1 -> " << strExample1 << std::endl; std::cout << "strExample2 -> " << strExample2 << std::endl; return 0; }
strExample1 -> This is with numbers: 1, 2, 3, 4. strExample2 -> A
int
-2147483648
2147483648
#include <iostream> int intExample1 = 1; int intExample2 = -1024; int main() { std::cout << "intExample1 -> " << intExample1 << std::endl; std::cout << "intExample2 -> " << intExample2 << std::endl; return 0; }
intExample1 -> 1 intExample2 -> -1024
float
#include <iostream> #include <iomanip> float floatExample1 = 1.584; float floatExample2 = 1024.9876453; int main() { std::cout << "floatExample1 -> " << floatExample1 << std::endl; std::cout << "floatExmaple2 -> " << floatExample2 << std::endl; std::cout << "floatExmaple2 -> " << std::setprecision(20) << floatExample2 << std::endl; return 0; }
floatExample1 -> 1.584 floatExmaple2 -> 1024.99 floatExmaple2 -> 1024.9876708984375
double
#include <iostream> #include <iomanip> double dblExample1 = 1.584; double dblExample2 = 1024.9876453; int main() { std::cout << "dblExample1 -> " << dblExample1 << std::endl; std::cout << "dblExample2 -> " << dblExample2 << std::endl; std::cout << "dblExmaple2 -> " << std::setprecision(20) << dblExample2 << std::endl; return 0; }
dblExample1 -> 1.584 dblExample2 -> 1024.99 dblExmaple2 -> 1024.9876452999999401
10.1234567
10.1234567890123456
#include <iostream> #include <iomanip> float floatExample1 = 1.0 / 81; float floatExample2 = 0.0; int main() { for (int i = 0; i < 729; ++i) { floatExample2 += floatExample1; } std::cout << "floatExample2 -> " << std::setprecision(7) << floatExample2 << std::endl; std::cout << "floatExample2 -> " << std::setprecision(15) << floatExample2 << std::endl; return 0; }
floatExample2 -> 9.000023 floatExample2 -> 9.00002288818359
#include <iostream> #include <iomanip> double dblExample1 = 1.0 / 81; double dblExample2 = 0; int main() { for (int i = 0; i < 729; ++i) { dblExample2 += dblExample1; } std::cout << "dblExample2 -> " << std::setprecision(7) << dblExample2 << std::endl; std::cout << "dblExample2 -> " << std::setprecision(15) << dblExample2 << std::endl; return 0; }
dblExample2 -> 9 dblExample2 -> 8.99999999999996