What it does:
Another program which I created in labs in uni, as a task. It randomly generates a number, the user would then enter a guess and it would return either too low or too high allowing them to decide whether or not they need to increase or decrease their guess.
Code:
#include <iostream> #include <cstdlib> #include <ctime> #include <conio.h> using namespace std; int main() { srand((int)time(0)); int randomNumber = rand()%100; int userGuess; do { cout << "\nPlease enter a number between 0 and 100" << endl; cin >> userGuess; if(userGuess>randomNumber) { cout << "Your guess is too high" << endl; }//if else if(userGuess<randomNumber) { cout << "Your guess is too low" << endl; }//else if }//do while(randomNumber!= userGuess); cout << "\n Your guess is correct and your number was " << userGuess << endl; _getch(); return 0; }//main
Thanks for the follow – did you notice timberbox.wordpress.com – I’m looking into computer generated poetry at the moment.
Hey, the blog address you sent me is protected so I can’t get on.
Thanks for pointing that out! In the middle of sorting blogs & I thought that one had been a bit quiet!! Not a programmer myself, but have IT offspring. Cheers, nexi