# What is the difference between 2 and 2.0000000 in problem From Heaven To Earth?

first one (with 2.0000000 is working) but second one (with only 2) is not working.

#include<math.h>

using namespace std;

int main()

{

``````int T,N,V1,V2;

cin>>T;

int arrn[T];

int arrv1[T];

int arrv2[T];

//v1 = chef,  v2 = elevator

for (int i = 0; i < T; i++) {

cin>>arrn[i]>>arrv1[i]>>arrv2[i];

}

for (int i = 0; i < T;  i++)

{

float timeOfChef = sqrt(2)*arrn[i]/arrv1[i];

float timeOfElevator =  (2.000000)*arrn[i]/arrv2[i];

//  cout<<"Elevator = "<<timeOfElevator<<endl<<"Chef = "<<timeOfChef<<endl;

if(timeOfElevator < timeOfChef)

{

cout<<"Elevator"<<endl;

}

else if(timeOfElevator > timeOfChef)

{

cout<<"Stairs"<<endl;

}

}

return 0;
``````

}

#include<math.h>

using namespace std;

int main()

{

``````int T,N,V1,V2;

cin>>T;

int arrn[T];

int arrv1[T];

int arrv2[T];

//v1 = chef,  v2 = elevator

for (int i = 0; i < T; i++) {

cin>>arrn[i]>>arrv1[i]>>arrv2[i];

}

for (int i = 0; i < T;  i++)

{

float timeOfChef = sqrt(2)*arrn[i]/arrv1[i];

float timeOfElevator =  (2)*arrn[i]/arrv2[i];

// cout<<"Elevator = "<<timeOfElevator<<endl<<"Chef = "<<timeOfChef<<endl;

if(timeOfElevator < timeOfChef)

{

cout<<"Elevator"<<endl;

}

else if(timeOfElevator > timeOfChef)

{

cout<<"Stairs"<<endl;

}

}

return 0;
``````

}

You must have heard of floating point division and integer division. so when you divide 5/2 in c++ it’s output is 2 ( integral part ) but when you do (1.0 * 5) / 2 you get 2.5 as output. that’s the difference and same is happening with your code.