-1

Ok, im not that much of a geeky smart guy in C++,
but i've got some skillz..
so im trying to make a very simple game that will randomize
1 number for the computer and 1 number for the person using the program and whomever(person or computer) gets the highest number(lets say 1-10) wins, and keeps score also...
If anyone can just post here, or help me make this program in anyway that would be awsome!!!

11
Contributors
10
Replies
33
Views
10 Years
Discussion Span
Last Post by ichigo_cool
Featured Replies
0

As for keeping score, you could have two variables.

int games_won_by_computer;
int games_won_by_player;

Once you're done that game, you could try a guessing game where the user guesses a random number in as few tries as possible.

0

Ok, im not that much of a geeky smart guy in C++,
but i've got some skillz..
so im trying to make a very simple game that will randomize
1 number for the computer and 1 number for the person using the program and whomever(person or computer) gets the highest number(lets say 1-10) wins, and keeps score also...
If anyone can just post here, or help me make this program in anyway that would be awsome!!!

its very simple
wat exactly u want ?
source code ??

-1

// 07/08/10 04:52

/*
  Guess the computers Number game
*/

//main
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int main()
{
 double firmver = 0.01;; // Game version
 
 cout << "\t\t\tGuess Num " << firmver;
 cout << "\nCompete with the computer.\nTry to guess the right number!\nSee how thinks faster!\n\n";
 cout << "Do you want to play?(yes/no || y/n)" << endl;
 
 string playgame; // to check if player wants to play
 cin >> playgame;
 cin.get();
 
 // Does player want to play?
 if(playgame == "yes" || playgame == "YES" 
 || playgame == "Yes" || playgame == "y" 
 || playgame == "Y")
 {
  cout << "Press any key to start" << endl;
  
  //Game loop
  while(playgame == "yes" || playgame == "YES" 
 || playgame == "Yes" || playgame == "y" 
 || playgame == "Y")
  {
  int psnum; //player secret num
  int csnum; //computer secret num
 
 
 
 long pgnum; //player guess num   
 int cgnum; // computer guess num
 
 int amountpg = 1; // amount player guesses max 3 times per guess 
 int amountcg = 0; // amount computer guesses max 3 times per guess
 
 psnum = rand() % 50 + 1; // Initiliaze  player secret num from 1-50;
 csnum = rand() % 50 + 1; // Initiliaze  computer secret num from 1-50;
 cout << amountpg << endl;
 
while(amountpg != 3)
 {
 cout << "Please guess your number" << endl;
 
 cin >> pgnum;
 
 if(pgnum == psnum)
 {
  cout << "You guessed right" << endl;
  amountpg = 0;
 }
 
 if (pgnum > psnum)
 {
  cout << "It is too high" << endl;
  amountpg++;
   cout << amountpg << endl;
 }
 
 if (pgnum < psnum)
  {
  cout << "It is too low" << endl;
  amountpg;
   cout << amountpg << endl;
  }
}
  
   cout << "You guessed 3 times wrong! Concentrate on solving the next guess" << endl;
   psnum = rand() % 50 + 1; // Initiliaze  player secret num from 1-50;
   amountpg == 0;
   
}
}
}

Edited by Nick Evan: Added code-tags

2

Did half a programming class just register to post in this thread?

-1
#include<iostream>
#include<string>

using namespace std;

int main()
{
    string s;
    cout << "Please enter your first name followed by a newline\n";
    cin >> s;
    cout << "Hello, " << s << '\n';
    return 0; // this return statement isn't necessary

Edited by mike_2000_17: Fixed formatting

0

If you've got any c++ skillz, you should be able to make this. Learn about random number generation, loops and functions. Then you should be set for a number-style game. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.