我正在尝试使用float而不是整数来查找模数但是它不允许我找到它,我也不想将它更改为整数。代码如下。
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e,f,g,h,i,j,k;
cout << "Hey victim, its time to do some simple maths which you absolutely love\nNow enter a number -_- (All only integers) : ";
cin >> (a);
cout << "You entered this: " << a << endl;
cout << "Enter another number now!" << endl;
cin >> (b);
cout << "You entered this: " << b << endl;
c = a + b;
cout << "The sum of "<< "'" << a << "'" << "+" << "'" << b << "'" << "=" << c << endl ;
cout << "Now, type another number. lets multiply it with the sum !" << endl;
cin >> (d);
cout << "So, you entered this: " << d << endl;
e = c * d;
cout << "The product of the two numbers are -12" << endl;
cout << "Haha, just kidding, the product the numbers" <<"'"<< c << "'" << "and" << "'" <<d<< "'" << "=" << e << endl;
cout << "Well you got your answer, then why not subtract it? :)\nNow tell a number (and note that this number will be the which will be 'SUBTRACTED' " << endl;
cin >> (f);
cout << "So you entered this: " << f << endl;
g = e - f;
cout << "So the difference is " << "'" << e << "'" << "-" << "'" << f << "' = " << g << endl;
cout << "Now i feel like remainining in c++..\nOh and that 'reminds' of 'remainders'...\nYup now type an number so that we can find the remainder with the difference from the previous question\n(let this number be lesser than the difference and not 1)" << endl;
cin >> (h);
cout << "So you entered: " << h << endl;
i = g % h;
cout << "Hence the remainder when" << "'" << h << "' is divided by '" << g << "' =" << i << endl;
cout << "Now the last part comes, division, type a number which will be DIVIDED (try something divisible) ";
cin >> (j);
cout << "Sou you entered this: " << j << endl;
k = j / i;
cout << "Hence the quotient when" << "'" << j << "' is divided by '" << i << "' = " << k << endl;
cout << "This is the end of my small and simple math program, Hope you enjoyed it!" << endl;
system("pause");
return 0;