Example
#include <iostream.h>
main( )
{
int a, b;
cout << "Enter first number" ;
cin >> a;
cout << "Enter Second number" ;
cin >> b;
if(a<b)
{
cout << "First number is less than second n";
cout << "Their difference is :" << b-a;
cout << "Their sum is "<< a+b;
cout << "The remainder of a/b is" << a%b;
}
return 0;
}
The four statements after the if and between the curly braces are executed only if a<b. These four statements together with the braces represent a block of code. They are a logical unit: One of the statements cannot execute without the other also executing. In C++ the target of most commands can be either a single statement or a code block. Code blokes allow many algorithms to be implemented with greater clarity and efficiency. They can also help you better conceptualize the true nature of the routine.