/* Control Program */ #include #include #include #include #include #include #include char Pause () { printf ("\n Press Enter to continue..."); getch (); return 0; } int GetInt() { char number[80]; gets (number); return atoi (number); } int main (void) { clrscr (); //char name[80]; //puts ("What is your name?"); //gets (name); //puts ("\nHello,"); //puts (name); //Pause (); int x, y; while (x!=y) { clrscr (); randomize (); //int x = GetInt(); //printf ("Guess my number from 1 to 5: "); //scanf ("%d",&x); //fflush (stdin); cout << "Guess my number from 1 to 5: "; cin >> x; //y = rand() %5 + 1; if (x < 1 || x > 5) { puts ("Error: number is out of range"); } //else if(x == 3) else if (x == rand()%5+1) { puts ("You guessed my number!"); return 0; } else { puts("Try again"); } Pause(); //return 0; } }