{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

wednesday_programming - ECE 190 Midterm Exam 1 Spring 2011...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 190 Midterm Exam 1 Spring 2011 Wednesday, February 16, 2011 In this assignment, you will need to write a program that guesses a number that the user picks. First, your program should tell the user to pick a number between 0 and 100 by printing " Come up with a number between 0 and 100. " Then, your program will guess the value, and the user will enter either > , < , or = , telling your program that your guess is too small, too big, or exactly right. You will use the binary search method to guess a number, meaning that if you know the number is between a and b , you will guess ( a + b )/2. Your guesses must be integer, so if a + b is odd, please round down. You must use all the information the user provides in each round. Continue to make guesses until the user enters = . Sample run of your program when user guessed number 73 must look like this: Come up with a number between 0 and 100. I guess 50. > I guess 75. < I guess 62. > I guess 68. > I guess 71. > I guess 73. = Note that if you use scanf to take your user input, some of the characters scanned by scanf
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online