fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a = 100000;
  6. int b = 100000;
  7. long c = a*b/2;
  8. cout<<"Normal multiplication: "<<c<<endl;
  9.  
  10. long d = (long)a*b/2;
  11. cout<<"Using typecasting: "<<d<<endl;
  12. long a1 = 100000;
  13. long b1 = 100000;
  14. long c1 = a1*b1/2;
  15. cout<<"Using long: "<<c1<<endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Normal multiplication: 705032704
Using typecasting: 5000000000
Using long: 5000000000