I'm trying to write a program that asks a user to enter the number of cookies they bought and then it is supposed to tell the user how many candybars/candyballs they can get for free. It won't run and I don't even know where to start correcting errors. Can I get some pointers?(3 cookies> 1 candybars and <3 cookies =1 candy ball)
Your problem is your not initializing your variable. When your program runs cookies will get a value from cin but freecandybar and freecandyball are both in an if statement so they may or may not get a value and yet your out putting their value. to initialize them simply int cookies, freecandybar = 0 ,freecandyball = 0;
other pointers
- what if the user enters 3?
-how will you output it if they get a candy ball and not a bar?