Write a c program that will present the user with a menu of


Computer Science

Program-

Write a C++ program that will:

Present the user with a menu of choices:

1. Random number
2. String
3. Type Casting
4. Integer Math

Then, in an if-else if structure (or switch) write the code for each option.

Option 1:

Write out a random number in the range of -5 to 5 (including both 5 and -5). The program should be able to write out a different random number each time the program is run.

Option 2:

Prompt the user and read in a string (that contains blank spaces) from the keyboard. Write out the length of the input string along with the first and last characters in the string.

Option 3:

Ask the user for an integer in the range of 33-126, and read this integer in from the keyboard. Treating this integer as an ASCII value, write out the character that the number represents.

Then, ask the user for a character input and read their input into a char variable. Write out the ASCII value that the computer uses to represent this input character.

Option 4:

Ask the user for 2 integers and read them into 2 int variables (i.e.A,B). Using only +=, -=, and *=,
add the two int variables and store the result in the first input variable ( A <- A + B)
subtract the first input variable from the second, storing the result to the second (B <- B - A).
add the two variables and store the result to the first input variable (A <- A + B)
multiply the second variable by -1 and store the result back into the same variable (B <- B * -1).

Write out the new values of the two variables (in original order A,B) Write out text messages with all numeric output to explain what has been done

Required Comments:

Name block (your name, course number, assignment number)

After the name block: A simple description of what the program does. Before each option in the if-else if, briefly say what that section is for.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a c program that will present the user with a menu of
Reference No:- TGS01579211

Now Priced at $30 (50% Discount)

Recommended (99%)

Rated (4.3/5)