#include "std_lib_facilities.h"
int main()
{
cout<<"Hey there, give me two numbers please.\n";
int v1;
int v2;
cout<<"First value please...\n";
cin>>v1;
cout<<"Second value please...\n";
cin>>v2;
cout<<"You've chosen v1("<<v1<<") and v2("<<v2<<").\n\n\n";
cout<<"Now for some mathematical magic.\n";
cout<<"Which is greater?\n";
if (v1>v2){
cout<<v1<<" is GREATER than "<<v2<<".\n";
}
if (v1<v2){
cout<<v1<<" is LESS than "<<v2<<".\n";
}
cout<<v1<<" + "<<v2<<" = ";
cout<<v1+v2<<"\n";
cout<<v1<<" - "<<v2<<" = ";
cout<<v1-v2<<"\n";
cout<<v1<<" * "<<v2<<" = ";
cout<<v1-v2<<"\n:";
}
/ is a bit of a weird operator. There are two versions: integer divide and floating point divide.
Suppose you had int v1=3 and int v2=2 then v1/v2 would give 1 (not 1.5) (since the output is an integer). So to get a floating point result you need to force a conversion. The double(v1) part converts v1 from int to double. Then the / operator sees a double on its left hand side and so uses floating point divide. Floating point divide must have floating point inputs, so v2 is automatically converted to a double as well.