/* This program demonstrates: * 1. Using cout to print literals, variables and text prompts for clarity * 2. Declaring, initializing and using variables of different primitve types * 3. The char type for single character data * 4. The 3 other integer types - short, int and long * 5. Different ways of representing an integer - decimal, octal, hexadecimal * 6. The 2 major floating point types - float and double * 7. Fixed and scientific notations for floating point numbers * 8. The cin object, used to read values into a variable. * * Variables: * Declaring a variable is us telling C++ to make room in memory to * hold a value. Variables have 5 properties - name, type, size, value * and address. * The name of a variable is an identifier. Follow rules and conventions * for naming identifiers. * The identifier is just the "word" we use to refer to the value in * the variable. Conventionally, it makes sense in context, but it doesn't * have to, in order to just produce the required output. * Initialization is giving the variable its first value, this value may * change later. If we do not initialize variables, the leftover "junk" * value might bleed into our program and produce the wrong result. */ #include using namespace std; int main() { /* bool is the C++ boolean type. It can only hold one of two values: * true and false. * 0 is interpreted as "false", Anything not 0 is "true" * C++ will print 1/0 instead of true/false * "true" and "false" are c++ keywords. */ bool ans; ans = true; cout<<"ans = "<< ans << endl; /* The char type is an integer type that can be used to store * single characters. The character stored in a char variable * must be in single quotes. The value in the char variable is * not associated in any way with the name of the variable. * Any single keystroke character can be stored in a char variable */ char letter; // declaration letter = 'B'; //initialization cout<<"letter: "<>letter; cout<<"User entered: "<>sideLength; double area = sideLength * sideLength; cout<<"The area is "<