double num1=3.3;
double num2=3.8;
//print output and round off
cout<<floor(num1+0.5)<<endl;
cout<<floor(num2+0.5)<<endl;
My task is to round the number first and then cast it to integer: the output of num1 and num2 after round off should be respectively 3.000000
and 4.000000
. How should I cast it to int
to get the aboved mentioned answers 3
and 4
?