- topic
- Code
- Explanation
- to sum up
topic:
A/B Problem
Write a program which reads two integers a and b, and calculates the following values:
- A ÷ B : D (in Integer) // find integer division
- of REMAINDER A ÷ B : R & lt (in Integer) // division remainder
- A ÷ B : F (in Real Number) // division result five significant digits reserved
Code:
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
double fa = a, fb = b;
printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
return 0;
}
Explanation:
The entire C language library in C ++ primarily because precision is more complicated character on the introduction of the C language would be a lot easier. A / B is the integer part of the division request, A% B seek a remainder portion of the rear division, but relates to the fractional part or the need to convert to a double mode, in calculations.
to sum up:
Involving decimal calculations, the decimal point digit reference C language library, character conversion accuracy.