#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int d;
cout << "Write a number: ";
cin >> a;
cout << "Write another number: ";
cin >> b;
if(d != 0)
{
d = a * b;
cout << a << " x " << b << " = "; cin.get();
}
cin.get();
return 0;
}
3 replies to this topic
#1
Posted 28 July 2010 - 07:45 AM
Hey! I wanted to make a calcultor for multiplation only. When i compiled, it had 1 succeeded. But it have a little bug at the end. Could you please fix it. Thanks!
|
|
|
#2
Posted 28 July 2010 - 08:13 AM
does this do what you want?
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int d;
cout << "Write a number: ";
cin >> a;
cout << "Write another number: ";
cin >> b;
d = a * b;
cout << a << " x " << b << " = "<<d;
cin.get();
cin.get();
return 0;
}
#3
Posted 28 July 2010 - 08:17 AM
What? Why are you using the cin.get() method?
I'm guessing it isn't printing out your end result? Another problem is that d isn't initialized, so when that if statement checks, it should error. It only requires the use of 2 variables, because they can just be multiplied together in the last statement.
Try using this instead.
I'm guessing it isn't printing out your end result? Another problem is that d isn't initialized, so when that if statement checks, it should error. It only requires the use of 2 variables, because they can just be multiplied together in the last statement.
Try using this instead.
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << "Write a number: ";
cin >> a;
cout << "Write another number: ";
cin >> b;
cout << a << " X " << b << " = " << a * b << endl;
}
#4
Posted 28 July 2010 - 08:21 AM
Sdyess i wanted to fix the same, but thought i'll only fix what was wrong :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









