The following is the code for my program that is supposed to choose a random number and then get the user to guess it by using the basic hints. It seems like it should work but it keeps coming up with the error:'else' without a previous 'if'. it is getting really annoying. Hope someone can help.
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int main()
{
int secretnum;
int getint;
srand (time(NULL) );
secretnum=rand() % 10;
cout<<"guess a number between 1 and 10_";
cin>>getint;
if (secretnum<getint)
cout<<"try a lower number";
goto loop;
else if (secretnum>getint)
cout<<"try a higher number";
goto loop;
else
cout<<"that is correct";
loop:
cout<<"Enter another number between 1 and 10_";
cin>>getint;
return 0;
}
I am using code::blocks. I hope its not to abvious i have only been programming for a couple weeks.
thanks