#include <iostream>
#include <string>
usingnamespace std;
int color; // Color should be a string because you aren't looking for integers.
cin >> color;
// You want the user to input the color and the shape, therefore you should not initialize it
string color = "color"; // You can instead initialize it as: string color = "";
string shape = "shape";// You can instead initialize it as: string shape = "";
getline( cin, color);
getline( cin, shape);
// You do no use single '=' rather you use '==' because you want to compare
// the user's input for color rather than setting color to "yellow"
// Learn the logical operator '&&' and '||'. This allows you to use only a single if-else statement
if (color = "yellow")
{
if (shape = "circular")
{
cout << "apple" << endl;
}
elseif (shape = "oval")
{
cout << "mango" << endl;
}
}
elseif (color = "red")
{
if (shape = "circular")
{
cout << "apple" << endl;
}
elseif (shape = "oval")
{
cout << "mango" << endl;
}
}
system ("pause");
return 0;
}
You will find it useful to compile with all warnings enabled.
You will find it useful to compile your code often, to fix errors as they arise.
Ideally, except while you're in the middle of a single particular edit, your code should be ready to compile and test. Source control can help with this.