This is what I'm trying to do:-
double x = 4.0
double y = 4.0
x+y = 8.0
The input has to be of double type only (given condition of the problem).
This is what I'm trying to do:-
double x = 4.0
double y = 4.0
x+y = 8.0
The input has to be of double type only (given condition of the problem).
printf("%.1lf", yournumber);
will do the trick. This will print value to 1
decimal place. In case number is 1.123
, printed number will be rounded, in this case to 1.1
.