0

enter image description here

This is what I have finally arrived at, I am getting 3 errors unused variable, undecalred variable, undeclared identifier minutes, even after declaring minutes outside my loop, I still get an error, I also moved my printf into the loop. error still.

help please.

Thanks

0

Because minutes is being used as the control var for the do/while loop, it must be declared before the do loop. It's also good form to initialize it at that time too. Also, be sure that you aren't redeclaring it inside the loop (with the keyword int), which would create a second shadow variable with the same name.

int minutes = -1;
do
{
   minutes = ...;
   ...
} while minutes < 0;
...

When a var is declared inside a set of curly braces, it only exists inside that immediate pair of curly braces. It ceases to exist outside of the immediately closest braces surrounding it. This is called variable scope and will be discussed in a later lecture.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • It did help, my code is working fine now, I was re-declaring minutes in the loop with the key word int. Thanks alot.
    – Cnewbie
    May 14 '17 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .