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 19:40

>>63
I saw it when you posted it, and I was quite impressed; I guess I didn‘t respond though. Probably because I don‘t have a 32-bit windows box to run it on, and I suspect it wouldn‘t run under wine. I can more-or-less see what it‘s doing, though.

Well, I guess I should post mine somewhere, since it can dump a syntax tree. It‘s written in dead dog¹, is disgusting in a porcine fashion, and generates a 5MB executable², but it works.

Have a look at http://filebin.ca/xvfkdb/fjolnir.tar.gz if you‘re bored and understand Haskell. I've only implemented the parts of "GRUNNUR" that I've been interested in so far, which isn't a great deal.

¹ ;_;.
² Then again, most Haskell programs does this.

$ ./Main
"GRUNNUR"> 1+2+3+4+5+6
(((((1 + 2) + 3) + 4) + 5) + 6)
21
"GRUNNUR"> \hali \haus \haus [1,2,3,4,5,6]
(\hali (\haus (\haus [1,2,3,4,5,6])))
Desugared: (\hali (\haus (\haus (1 : (2 : (3 : (4 : (5 : (6 : [])))))))))
----
3
"GRUNNUR"> fyrir(x := 1, y := 0; x <= 10; x := \stækka x) lykkja y := y + x lykkjulok
fyrir((x := 1),(y := 0);(x <= 10);(x := (\stækka x)))  lykkja (y := (y + x)) lykkjulok
55
"GRUNNUR">█

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