Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Change the following so that for any input number, the changed program produces exactly the same output as the original, but the changed program

1.  Change the following so that for any input number, the changed program produces exactly the same output as the original, but the changed program uses a while loop instead of a for loop for the inner loop. and change it so that for any input number, it produces exactly the same output, but uses a do-while loop instead of a for loop for the outer loop. Be careful! (Hint: How does it behave if len is not positive?) You may need to add a little additional code to make sure the program behaves identically to the program.

 

2. Assume codeSection has been previously declared as an int and given as its value the number of a section of the California Penal Code. Write a switch statement that for any value of codeSection, produces exactly the same output as the following if statement.

 

1 #include using namespace std; int main() { int len; cout > len; for (int i = 0; i < len; i++) { for (int j = i+1; j < len; j+) { cout

Step by Step Solution

3.47 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

1 Here is the modified code for you in... 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

Document Format ( 2 attachments)

PDF file Icon
63609aca7e7db_232725.pdf

180 KBs PDF File

Word file Icon
63609aca7e7db_232725.docx

120 KBs Word File

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

Modern Control Systems

Authors: Richard C. Dorf, Robert H. Bishop

12th edition

136024580, 978-0136024583

More Books

Students also viewed these Accounting questions

Question

What do you think?

Answered: 1 week ago