/***************************************************************
* Name: Prof. Rafael Orta
* Course: Computer Science & Programming
* Class: CS04103 Section: 1 & 2
* Assignment Date: 09/10/20
* File Name: CSNP-Chapter2.cpp
*****************************************************************
* ID: Chapter 2
* Purpose: Ilustrate chapter 2 concepts
*
*****************************************************************/
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
// Main program
int main()
{
// Declaring constants and variables
const float PI = 3.141592;
int age = 0;
char letter = 'C';
string name = "Rafael";
bool old;
// Exploring the cout object. These are executable statements.
cout << "\n******** Exploring the cout startement *******\n" << endl;
cout << "Hello Class, this is your section 1 and 2 combined lecture" << endl;
cout << "You can use multiple cout statements and cout";
cout << "cout statements can" <<
"be written in more than one line";
cout << "\nNotice the endl command and the \"\\ \bn\" command used to leave a blank space" << endl;
// Working with constants
cout << "\n******** Exploring the use of constants *******\n" << endl;
cout << "The value for PI is: " << PI << endl;
//PI = 5.92124; // This line will cause an error as you can't change a constant.
// Working with variables
cout << "\n******** Exploring the use of variables *******\n" << endl;
time_t t = time(NULL);
tm* timePtr = localtime(&t);
cout << "What is your age?: " ;
cin >> age;
cout << "You were born around : " << (timePtr->tm_year + 1900) - age << endl;
cout << "Your age was loaded to the memory location: " << &age << endl;
age = age + 10;
cout << "In 10 more years you will be: " << age << " years old." << endl;
cout << "The size of an integer in this compiler is " << sizeof(int) << " bytes." << endl;
cout << "The size of a float in this compiler is " << sizeof(float) << " bytes." << endl;
// Working with char data types
cout << "******** Exploring the use of the char data type *******\n" << endl;
cout << "\nThe integer value of the uppercase letter " << letter << " is " << int(letter) << endl;
// Working with string data types
cout << "\n******** Exploring the use of the string data type *******\n" << endl;
cout << "My name is: " << name << endl;
cout << "A string is an array of Characters, thus I can reference to member of the array like: " << name[0] << endl;
// Working with boolean data types
cout << "\n******** Exploring the use of the boolean data type *******\n" << endl;
old = age >= 30 ? true : false ;
cout << boolalpha << "Are you over 30?: " << old;
return 0;
}