diff --git a/src/Ch00/CodeDemo.cpp b/src/Ch00/CodeDemo.cpp index 2613d2c3..613e0ee0 100644 --- a/src/Ch00/CodeDemo.cpp +++ b/src/Ch00/CodeDemo.cpp @@ -1,5 +1,5 @@ // Learning C++ -// Exercise 00_03 +// Exercise 00_03 with modifications // Using the exercise files on GitHub, by Eduardo CorpeƱo #include diff --git a/src/Ch02/02_03b/CodeDemo.cpp b/src/Ch02/02_03b/CodeDemo.cpp index 8b365648..90518785 100644 --- a/src/Ch02/02_03b/CodeDemo.cpp +++ b/src/Ch02/02_03b/CodeDemo.cpp @@ -4,9 +4,27 @@ #include +int a, b = 5; // single line comment + +/* Multi +* line +* comment */ + int main(){ - std::cout << "Hi There!" << std::endl; - + bool my_flag; + a = 7; + my_flag = false; + std::cout << "a = " << a << std::endl; + std::cout << "b = " << b << std::endl; + std::cout << "flag = " << my_flag << std::endl; + my_flag = true; + std::cout << "flag = " << my_flag << std::endl; + std::cout << "a + b = " << a + b << std::endl; + std::cout << "b - a = " << b - a << std::endl; + unsigned int positive; + positive = b - a; + std::cout << "b - a (unsigned) = " << positive << std::endl; + std::cout << std::endl << std::endl; return (0); } diff --git a/src/Ch02/02_05b/CodeDemo.cpp b/src/Ch02/02_05b/CodeDemo.cpp index eed63d20..b6104f1e 100644 --- a/src/Ch02/02_05b/CodeDemo.cpp +++ b/src/Ch02/02_05b/CodeDemo.cpp @@ -6,7 +6,22 @@ #include int main(){ - + auto a = 8; + auto b = 12345678901; + auto c = 3.14f; + auto d = 3.14; + auto e = true; + auto f = 'd'; + auto g = "C++ rocks!"; + + std::cout << "The type of a is " << typeid(a).name() << std::endl; + std::cout << "The type of b is " << typeid(b).name() << std::endl; + std::cout << "The type of c is " << typeid(c).name() << std::endl; + std::cout << "The type of d is " << typeid(d).name() << std::endl; + std::cout << "The type of e is " << typeid(e).name() << std::endl; + std::cout << "The type of f is " << typeid(f).name() << std::endl; + std::cout << "The type of g is " << typeid(g).name() << std::endl; + std::cout << std::endl << std::endl; return (0); }