* Program to swap two numbers using a temporary variable with each statement explained with comments *
#include // headerfile for cout statement
using namespace std; // include standard library files
int main() // main()- starting point of the program with int return type
{ // start of main()
int a = 5, b = 10, temp; // 3 variables where a,b are initialised and a temp variable
cout << "Before swapping." << endl; // print statement
cout << "a = " << a << ", b = " << b << endl; // values before swapping
temp = a; // assign a to temp
a = b; // assign b to a
b = temp; // final step in swapping with assigning temp ,ie, a to b
cout << "\nAfter swapping." << endl; // print statement
cout << "a = " << a << ", b = " << b << endl; // values after swapping
return 0; //return value required coz on int return type of main()
} // termination of main()
// Semi-colon ';' is termination of each valid C++ statement