Intro

Trying to get some help for an assignment.

When declaring variables (Ex. Ice cream) and you want the user to input 0 for Vanilla, 1 for Chocolate and 2 for Strawberry, do you declare [int icecream], [int vanilla], [int chocolate], and [int strawberry]? Or just [int icecream]?

In my assignment the teacher tells us to use [const int vanilla = 0] since there are going to be if/else statements such as

if (icecream == chocolate)
<blah, blah, blah>

Hope that makes sense, its hard to explain what I'm getting at...
She's right.

1
2
3
4
5
const int vanilla = 0;
const int chocolate = 1;
const int strawberry = 2;

int icecream;


You could use an enum:
1
2
3
enum IceCreamFlavors {vanilla, chocolate, strawberry};

IceCreamFlavors icecream;


Hope this helps.
Haven't gotten to enum yet! But thanks for the quick help.
Topic archived. No new replies allowed.