Guest User

Untitled

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. // exercise   1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using std::cout;
  7. using std::cin;
  8. using std::endl;
  9.  
  10. #include <cstdlib>
  11. #include <ctime>
  12.  
  13. int playgame()
  14.  
  15. void main()
  16. {
  17.     srand(time(0));
  18. }
  19.  
  20. int playgame()
  21. {
  22.     int number, rand;
  23.     rand = 1 + computernumber() % 1000;
  24.  
  25.     cout<<"I have a number between 1 and 1000"
  26.         <<"Can you guess my number?"
  27.         <<"Please type your first guess";
  28.     cin>>number;
  29.  
  30.     if(number >= rand)
  31.         cout<<"too high. Try again";
  32.    
  33.     else if(number <= rand)
  34.         cout<<"Too low. Try again";
  35.     else if(number == rand)
  36.         cout<<"Excellent! You guessed the number"
  37.             <<"Would you like to try again (y or n)?";
  38. }
Add Comment
Please, Sign In to add comment