WackyJacky
Head Gardener
Was messing around with a program we wrote in class. Trying to write it in C++, with a bit of added functionality. However I keep getting the wrong output. Any help? (even if you don't know C++ it's simple enough that you can probably figure out what's wrong.)
Output that it returns:
enter a: 1
enter b: 1
enter c: 3
1 is equal to 1
3 is equal to 3
Code:
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "enter a: ";
cin >> a;
cout << "enter b: ";
cin >> b;
cout << "enter c: ";
cin >> c;
if (a <= b)
{
if (a=b)
{
cout << a << " is equal to " << b << endl;
}
if (a<b)
{
cout << a << " is less than " << b << endl;
}
}
if (b <= c)
{
if (b=c)
{
cout << b << " is equal to " << c << endl;
}
if (b<c)
{
cout << b << " is less than " << c << endl;
}
}
else
{
cout << a << " was not less than or equal to " << b
<< " which was not less than or equal to " << c << endl;
}
return 0;
}
Output that it returns:
enter a: 1
enter b: 1
enter c: 3
1 is equal to 1
3 is equal to 3