Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2009-06-12 6:31

Hello /prog/.

I know very little about C++. and my only other experience with programming is a calculator in freeBasic.

I studied how to programm a guessing game from the internets but my 4.9.9.2 Dev C++ fail to compile it.

this is what i wrote:

#include <iostream>
#include <ctime>
#include <conio.h>
using namespace std;

int main(void){
   
    int UPPER_LIMIT;
    int random;
    int userguess;
    char playAgain;
    srand(static_cast<unsigned int>(time(0)));
    random = rand()%20+1;
   
    do{
                           
    while(userguess !== random){
   
    cout << "Please enter a number between 1 - 20: ";
    cin >> userguess
   
    if(userguess == random){
                 cout << "wow good job you guessed right." <<endl;
                 }
                
    else if(userguess > random){
    cout << "that number is too low" <<endl;
    system("CLS");
}
        
    else if(userguess < random){
         cout << "that number is too high" <<endl;
    system("CLS");
   
    }
}

cout << "Do you wish to play again? y//n: ";
cin >> playAgain;


} while(tolower(playAgain == 'y');


getch();
return 0;
}

PLEEAASE HAAALP /PROG/.
Thanks in advance.

Name: Anonymous 2009-06-14 1:45

Dear OP, I fixed you're code.

"dagame" < aðal {
aðal -> stef(;)
    staðvær goal, guess, left := 10
    stofn
        goal := slembi(;) % 1000 + 1,
        lykkja
            \skrifafjöl left,
            \skrifastreng " guesses left\nGuess: ",
            guess := lesa(;),
            ef ekki \ertala guess þá
                \skrifastreng "wat\n"
            annarsef guess < goal þá
                \skrifastreng "Too low\n",
                left := left - 1
            annarsef guess > goal þá
                \skrifastreng "Too high\n",
                left := left - 1
            annars
                \skrifastreng "You won!\n",
                út
            eflok,
            ef left <= 0 þá
                \skrifastreng "You lost ;(\n",
                út
            eflok
        lykkjulok
    stofnlok
}
*
!{
slembi -> stef(;)
    innflutt sædi
    stofn
        ef ekki sædi þá
            sædislembi(;)
        eflok,
        sædi := sædi * 649 + 1801 + sædi / 1023
    stofnlok

sædislembi -> stef(;)
    innflutt sædi
    staðvær k,m,s,i
    stofn
        sækjatíma(k,m,s;),
        sædi := k*3600 + m*60 + s,
        fyrir(i := 0; i < 10; i := i+1) lykkja
            slembi(;)
        lykkjulok
    stofnlok
}
*
{ sædi -> breyta }
*
"GRUNNUR"
;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List