#include <stdio.h> // include the necessary files
#include <iostream>
using namespace std;
int main()
{
// declare a new variable myNumber as integer
// it can now hold numbers (..,-2,-1,0,1,2,3,...n).
// the default value = 0.
int myNumber;
// declare a new variable myDecimalNumber as double
// it can now hold decimalnumbers ( -2.7 or 1.5)
double myDecimalNumber;
// declare a new variable myChar as char. It can hold a character.
char myChar;
// declare a new variable myBool as boolean
// it can hold true or false (1 or 0). The default value = false.
bool myBool;
// define the variable myNumber and set value equal to 5
myNumber = 5;
// define the variable myDecimalNumber and set value equal to 8.8;
myDecimalNumber = 8.8;
// define the variable myChar as the character a.
myChar = 'a';
// define the variable myBool as true.
myBool = true;
// Display myNumber
cout << "my number: " << myNumber << endl;
// Display myDecimalNumber
cout << "my decimal number: " << myDecimalNumber << endl;
// Display myChar
cout << "my character: " << myChar << endl;
// Display myBool
cout << "my boolean: " << myBool << endl;
getchar(); // wait for a key to be pressed
return 0; // return zero
}
Download Visual C++ Source Code
I hope you found this c++ tutorial useful!
Don't forget to mention Apron Tutorials in your References!