Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // exercise 1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using std::cout;
- using std::cin;
- using std::endl;
- #include <cstdlib>
- #include <ctime>
- int playgame()
- void main()
- {
- srand(time(0));
- }
- int playgame()
- {
- int number, rand;
- rand = 1 + computernumber() % 1000;
- cout<<"I have a number between 1 and 1000"
- <<"Can you guess my number?"
- <<"Please type your first guess";
- cin>>number;
- if(number >= rand)
- cout<<"too high. Try again";
- else if(number <= rand)
- cout<<"Too low. Try again";
- else if(number == rand)
- cout<<"Excellent! You guessed the number"
- <<"Would you like to try again (y or n)?";
- }
Add Comment
Please, Sign In to add comment