c++ programming function index

  • cout: used to print sentences or varibales into the terminal.
cout << "Hello \n"; // prints Hello the starts a new line 
cout << "Hello" << name << endl; // prints Hello followed by a pre-defined variable 'name' endl stands for end line and is an alternative to \n.
  • cin: used to enable inputs from the user
cin >> name; //enabled the user to input a value for name (must first be defined as a string)
cin >> age;
  • int: used to initialise integer variables, that is whole numbers positive and negative.
int age; // initialises age with no start value 
int age = 7; // initialises age as 7
  • string: used to initialise a string variable such as words
string name; //initialises an empty variable name
string name = Tasha; //initialises a string Tasha

Leave a comment