EverEffects Backup Forum
Welcome To We Can't Program Forums, Please Log In To Access All Forums.

Enjoy Your Stay

- Staff
EverEffects Backup Forum
Welcome To We Can't Program Forums, Please Log In To Access All Forums.

Enjoy Your Stay

- Staff
EverEffects Backup Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

EverEffects Backup Forum

Designers World
 
HomePortalLatest imagesRegisterLog in



 Simple guessing game Resize


Share | 
 

 Simple guessing game

View previous topic View next topic Go down 
AuthorMessage
Fred
Staff
Staff
Fred

Posts : 33
Join date : 2010-05-27
Age : 31
Location : Oklahoma

Simple guessing game _
PostSubject: Simple guessing game   Simple guessing game EmptyThu Jun 03, 2010 5:24 pm
This is only a guessing game. Pretty basic though but try it out

Code:
#include<iostream>
#include<cstdlib>

using namespace std;

int main()
{
 
    double guess, chance=1, random;
 
    cout << "Enter your guess : ";
 
    srand((unsigned)time(0));
    random = (rand()%10)+1;
 
    while (chance <= 3)
    {
       
          cin >> guess;
       
          if (random == guess)
          {
            cout << "You're right.." << endl << endl;
            system("PAUSE");
            return 0;
          }
          else
          {
              cout << "Try again..." << endl;
          }
       
          chance ++;
    }
 
    cout << "The no. was " << random << endl;
 
    system("PAUSE");
    return 0;
 
}
Back to top Go down
http://wcpforums.friendhood.net
 

Simple guessing game

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
EverEffects Backup Forum :: C/C++/C#/VisualC++-
Jump to:  


   [Valid RSS]





Make a forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com