0
C++ please check the Description for details
Write a program to calculate the remainder of 234 divided by 13. Remember that the / operator throws away the remainder. Hint: divide 234 by 13 and then multiply it by 13 again
4 ответов
+ 1
234%13
isn't it enough
0
This is just the way that remainder is calculated if you had to do it yourself.
For example if you do this:
int x = 5;
int y = 2;
int z = 5/2; the answer is 2, not 2.5 since z in an int and the answer is "rounded down" since int's cannot handle fractional parts.
You can make use of this to calculate the remainder of any division:
int r = 234/13; //This gives you the "rounded down" int
r = r*13; //Multiply again with original divisor...
r = 343 - r; //...and subtract from original number to get the remainder.
Or, much easier, do 234%13 to get the same result.
0
#include <iostream>
using namespace std;
int main()
{
cout << "The remainder of 234/13 is " << endl;
cout << 234 / 13 * 13 - 234 << endl;
return 0;
0
#include <iostream>
using namespace std;
int main()
{
cout << "The remainder of 234/13 is " << endl;
cout << 234 -(234 / 13) * 13 << endl;
return 0;
}