Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that allows the user to guess a number 5 times. After each guess, the program will tell if the users number was

Write a program that allows the user to guess a number 5 times. After each guess, the program will tell if the users number was too low or too high, or it will give a congratulations, you won statement. The program also gets the users name and includes it in the output statements. Your algorithm may be in the comments at the top, or dispersed throughout the program as line comments.

How to do random

In order for the program to pick a number, you will use srand(). The following gives you instructions on how to do this.

  1. First, include cstdlib (C Standard Library) and ctime (C Time) at the beginning of your program.
  2. Before you list the variables, include a section called Seed Random and type the following:
    1. srand( time( NULL ) );
  3. Whenever you want to generate the random number you will have a variable that receives it:
    1. random1 = (rand() % 50) + 1;
    2. every time you use this line, itll give you a new random number from 1 to 50

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions