Click here to Skip to main content
12,999,653 members (65,286 online)

Beginner C++ Random Number Generator

Member 9790449 asked:

Open original thread
I am a beginner and I want to have a code with a random number generator, but my code does not follow what I would like it to follow.... PLEASE HELP! . This is what have so far... please help with any corrections, improvements, etc.

#include <iostream>;
#include <cstdlib> //drand function
#include <ctime> // time function
#include <windows.h> //Sleep function
using namespace std;
/* *****************
Oscar, Zamora
1/20/13
This program was made
so that people can 
understand and 
experience how video
games are made using
the language of C++
***************** */
 
//start( float radius); //Function Prototype
//float volumes( float radius); // Function Prototype
 
int main()
{
int num;
char choicei = 'i';
char choiceh = 'h';
char choices = 's';
char choicec = 'c';
char choiceb = 'b';
 
// Suspend program for 2 seconds
 
Sleep(2000);
//seed random number ganerator using the system clock
srand(static_cast<unsigned int> (time(0)));
//generate a random number between 1 and 13
num = rand() % 13 + 1;
 
// Welcome user to the introduction screen
cout << " BLACKJACK\n\n\n";
cout << " Thank youdsfafafd for playing this game!\n\n";
cout << " Press 'b' to Start the game\n";
cout << " Press 'i' for intructions on the game\n";
cout << " Press 'c' for credits on the game\n";
 
// Show the instructions
if (choicei == 'i')
{
  cout << " The game you will be playing is called 'Blackjack' or 'twenty-one'.\n This is a multiplayer games in which one of the players want to get cards";
}
 
if (choicec == 'c')
{
  cout << " The writer, producer, developer, and artist of this game is Oscar Zamora";
}
 
if (choiceb == 'b')
{
  do
  {
    //Tell the user what card they got
    cout << " You got" << num;
 
    // Add up all the user"s cards and print
    // Ask them if the y want to hit or stay
    cout << " Would you like to get hit ('h') or stay ('s')";
 
    //If they want to hit, loop back to generating a random number again otherwise let the computer get a hand
 
  }while (choices == 's');
}
}
Tags: C++, random

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100