Help with my code.

Hello I am a beginner coder and am having trouble finding why my code is having errors. I defined user input as color and I am pretty sure if I define a string that it should work later in the code. Please help!
Here is the problem:
The user will input a string representing a color (either "yellow" or "red"), followed by a second string representing a shape ("circular" or "oval").

If the user says "yellow" and "circular" or "red" and "circular" print out the word "apple"

If the user says "yellow" and "oval" or "red" and "oval" print out the word "mango"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
using namespace std;

int color;
cin >> color;

//int shape;
//cin >> shape;

string color = "color";
string shape = "shape";

getline( cin, color);
getline( cin, shape);

if (color = "yellow")
{ 
    if (shape = "circular")
    {
        cout << "apple" << endl;
    }
    
    else if (shape = "oval")
    {
        cout << "mango" << endl;
    }
}

else if (color = "red")
{
    if (shape = "circular")
    {
        cout << "apple" << endl;
    }
    
    else if (shape = "oval")
    {
        cout << "mango" << endl;
    }
}

      
    system ("pause");
    return 0;
}

You have no main function.

1
2
3
4
// Tell user what to do here
getline( cin, color);
// Tell user what to do here
getline( cin, shape);


you do not need
1
2
3
4
5
//string color;
//cin >> color;

//int shape;
//cin >> shape; 


to check a condition it's done like this
if (color == "yellow")
Topic archived. No new replies allowed.