0

this is my code for water.c but an error is still showing need a lil help thanks

#include <stdio.h>

int main(void)
{
    int minutes;
    int bottles;
}

do
{ 
    printf("minutes:\n");
    int minutes = get_int(); // an integer 

while (minutes > 0)
}

{ 
    printf("bottles:\n");
     bottles = mintues * 12; // the amount of bottles used
 }

 {
printf ("You took %i Minutes in the shower which means that you have used %i amount of bottles of water\n", minutes, bottles);
}

and I got an error

 ^
water.c:5:1: note: to match this '{'
{
make: *** [water] Error 1
~/workspace/pset1/ $ make water
    int bottles;        ^
^
~/workspace/pset1/ $ make water
    int bottles;        ^
water.c:10:1: error: expected identifier or '('
do 
^
3 errors generated.
make: *** [water] Error 1
~/workspace/pset1/ $ 

2 Answers 2

1

Your curly braces are all over the place. Furthermore, you need all of you code to be within the opening and closing in main. For example....

#include <stdio.h>
#include <cs50.h> //Don't forget to include this (it's what gives you getint()!)

int main(void)
{

     ALL CODE GOES HERE (At least for this simple code)

}
1

Simply put, the {} curly braces are badly placed throughout and there are too many. You should go back and review their usage, particularly in combination with main(), and with do{}while.

It would be easy for me to point out the specific issues, but it is better for you to research it and understand why you got the errors.

"Give a man a fish and feed him for a day. Teach him to fish and feed a man for a lifetime!"

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

1
  • I had research like you had said and now my code is Commented Aug 16, 2017 at 0:01

You must log in to answer this question.

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