It seems like the functions fun1
and fun2
should return the same values but the outputs are different. Can you explain why is it so?
#include <iostream>
using namespace std;
long long fun1(int, int, int );
long long fun2(int, int, int );
int main(){
int l = 1039, b = 3749, h =8473;
cout<<"Volume is equal to "<<fun1(l,b,h)<<endl;
cout<<"Volume is equal to "<<fun2(l,b,h)<<endl;
}
long long fun1(int length, int breadth, int height){
long long volume = length * breadth * height;
return volume;
}
long long fun2(int length, int breadth, int height){
return (long long)length * breadth * height;
}
output:
Volume is equal to -1355615565
Volume is equal to 33004122803