CPS 109 Midterm: CPS109_Mid_2009F

726 views5 pages
16 Oct 2018
Course
Professor

Document Summary

Question 1a) (5 marks) rewrite the following do loop into a while loop. int n = 1; double x = 0; double s; do s = 1. 0 / (n *n); x = x+s; n++; Question 1b) (5 marks) rewrite the following for loop into a while loop. for(i=0;i<50;i++); Question 2) (5 marks) given the following variable definitions, int v1,v2,v3; Ask the user to input three integers (one at a time). Read and store the input in each of these three variables. Your program should then sort the variables so that when the program ends the smallest value that was input will be in v1, the middle value input should be in v2 and the largest value will be in v3. You can make more variables if you need them. You need not write a whole class, just write the code required to do this task. An example run might look like (note: this is just an example)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions