This is the second video in the Learn C++ on the Mac video series. In this video tutorial, Mark will show you how to declare variables in C++ as well as initialize them. The most common C++ Primitive variable types wil be discussed including int, double, float, bool and char.
Main.cpp
#include <iostream> using namespace std; int main (int argc, char * const argv[]) { char name; //Declared the char variable called name name='M'; //Initialized the variable name cout<<"The value of name is: "<<name<<endl; int gameScore = 10900; //Combined initalization and declaration cout<<"The score is "<<gameScore<<endl; //short int - 2 byte integer //long int- Bigger integer in some architectures bool isPlaying = true; //boolean is a true or false value cout<<"Are we playing? " <<isPlaying<<endl; float gpa = 3.76; cout<<"My gpa was not " <<gpa<<"."<<endl; //Double is a more precise floating point variable return 0; }


