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

Enjoy Your Stay

- Staff

EverEffects Backup Forum

Designers World
 
HomePortalMemberlistRegisterLog in



 


Share | 
 

 Simple guessing game

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

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

PostSubject: Simple guessing game   Thu 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]





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