Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2) C++ Programming: Conditional Statement. Please include detailed comments on your code so it is easy to understand what has been done. Thank you very

2) C++ Programming: Conditional Statement. Please include detailed comments on your code so it is easy to understand what has been done. Thank you very much.

Question 2:

Based on the below program (at the end of this question), which displays a number between 10 and 19 inclusive, modify the program so that it displays 3 numbers between 1 and 6 inclusively. The program then displays the product of the 3 numbers. One of the messages may be displayed in each of the following cases:

- Bravo, if the product of the three numbers is greater than 140.

- Very Good, if the product of the three numbers is strictly greater than 108, but less than or equal to 140.

- Good, if the product of the three number is strictly greater than 50, but less than or equal to 108.

- Failure in the other cases.

Example 1:

The first number is 5.

The second number is 6.

The third number is 4.

The product of the three of is 120. Very good.

Example 2:

The first number is 1.

The second number is 2.

The third number is 3.

The product of the three of is 6. Failure.

Below is the code for the program, that you will need to modify:

#include // For cin et cout

#include // Fonction srand and time

using namespace std;

void main(void) // main Programme

{

int aleatoire; //Dclaration of variables

cout << "The maximum random value of rand() is : " << RAND_MAX << endl; // Displaying the random maximum value of rand()

srand((unsigned)time(0)); // Using srand to guarantee a random variable with rand() aleatoire = rand(); // Generation of the random variable up to RAND_MAX

aleatoire = (aleatoire % 10) + 10; // returns the remainder from 0 to 9 and with +10 implies from 10 to 19 inclusive

cout << "The random value between 10 and 19 is : "<< aleatoire << " ! "; // Show result

}

Please include detailed comments on your code so it is easy to understand how it is done

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

Which personal relationships influenced you the most?

Answered: 1 week ago