1 / 5

Homework #1: C++ Basics, Flow of Control, and Function Basics

Homework #1: C++ Basics, Flow of Control, and Function Basics. By J. H. Wang Mar. 13, 2012. Programming Exercises.

pennie
Télécharger la présentation

Homework #1: C++ Basics, Flow of Control, and Function Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Homework #1:C++ Basics, Flow of Control, and Function Basics By J. H. Wang Mar. 13, 2012

  2. Programming Exercises • Write a C++ program that allows the user to repeatedly enter integers until she inputs a 0 (zero). Then, your program should do the following:(a) count the number of positive values and the number of negative values in user input; (b) calculate the minimum and maximum;[Note: Do not count the ending input 0 in the result.][Note: Please do not use arrays because you don’t need them in this exercise.]

  3. Programming Exercises • Write a C++ program that asks the user to input an integer n and computes the value of n! = n*(n-1)*…*2*1. [Note: Please inform the user if the output value would be out of range for the data type that you used (i.e., int or long int).]

  4. You have r identical prizes to give away and a pool of n finalists. The finalists are assigned numbers from 1 to n. Write a function to randomly select the numbers of r finalists to receive a prize from n finalists. Make sure not to pick the same number twice. For example, given n=25 and r=4, picking finalists 3, 15, 22, and 14 would be valid but picking 3, 3, 31, and 17 would be invalid, because finalist number 3 is listed twice and 31 is not a valid finalist number.[Hint: input - n & r, output - a list of r numbers]

  5. Homework Submission • Due: 2 weeks (Mar. 27, 2012) • Submission instructions: • Homework submission Web site at: http://140.124.183.39/oop/ • Account: Please use your student ID as the username and password to login the Web site. • File names: Please name your file according to our homework. For example, HW1.zip or quiz2.rar.

More Related