Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ Quote of the Day I think that you'd find that the programmers who sit down and code at the beginning are only using

Language: C++

Quote of the Day

"I think that you'd find that the programmers who sit down and code at the beginning are only using that as a scratch pad. It's what's going on in their head that's important." -- Bill Gates

Lab 10

Instructor-assigned problem: Question 1.

You must choose a second problem to also submit a solution for.

Submit two .cpp files to Blackboard under Lab 10.

Follow this formatting for your .cpp file names: LastNameFirstName_Lab#.Question#.cpp

Example: SchleyRebecca_10.1.cpp 1. Write a complete C++ program that asks the user to type a big integer n. It should then ask 4 times for the user to type a smaller value of n and then terminate the program. However, if the user enters a value that is not smaller it should immediately say "Goodbye" and terminate the program. A sample run of the program: Type a big integer n: 100

Type a smaller value of n: 20

Type a smaller value of n: 10

Type a smaller value of n: 2

Type a smaller value of n: 1 Another sample run of the program: Type a big integer n: 100

Type a smaller value of n: 0

Type a smaller value of n: 0

Goodbye 2. Write a complete C++ program that does the following:It asks the user to enter an odd positive integer.The program reads a value n entered by the user. If the value is not legal, the program terminates.The program prints an n x n grid displaying a line running from the top left of the screen to the bottom right. The top left half of the line should be made with the character +, the bottom right half should be made with the character x and the very center should be a *.A sample run of the program: Enter value for n:

7

+

+

+

*

x

x

x 3. Write a complete C++ program that does the following:It asks the user to enter an odd positive integer.The program reads a value n entered by the user. If the value is not legal, the program terminates.The program prints an n x n grid displaying a large letter X. The left half of the X should be made with the character +, the right half should be made with the character x and the very center should be a *.A sample run of the program: Enter value for n: 7

+ x

+ x

+ x

*

+ x

+ x

+ x 4. Write a complete C++ program that does the following:The program asks the user to enter an integer between 1 and 20.If the user enters an illegal number, the program repeatedly asks the user to correct their number.If the user has not entered a correct number after 10 attemps, the program chooses 10 as the user's number.The program prints the cube of the user's number.

A sample run of the program: Enter an integer between 1 and 20: 100

Out of range. Enter an integer between 1 and 20: -1

Out of range. Enter an integer between 1 and 20: 5

The cube of your number is 125.

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

What is linear transformation? Define with example

Answered: 1 week ago