Have a look at the following programme.
// Example program
#include <iostream>
#include <string>
int main()
{
int n=7;
std::cout <<"n/2 = "<< n/2 << std::endl;
std::cout <<"n/3.3 = "<< n/3.3 << std::endl;
}
output :
n/2 = 3
n/3.3 = 2.12121
In above example,
- Expression "n/2" have been evaluated using integer division.
- Expression "n/3.3" have been evaluated using real-number division.
What are the rules for determine which division is used?