HW9
COP-3223H
Submit this project via git (not webcourses) using the Uploading homework to git documentation.
(
hw9-1.c) Hand-copy yourself without copy-and-paste the following program into a file on eustis and compile and run it.#include <stdio.h> int main(int argc, char **argv) { int num; int sum; int pow; // read an integer from the user scanf("%d", &num); pow = 1; sum = 0; while (num > 0) { sum = sum + pow; pow = pow * 2; num = num - 1; } printf("%d\n", sum); }
Describe in a comment in the program source code a summary of what this program is doing.
- (
hw9-2.c) Write a new version of the repeated guessing game where the user only gets a fixed number of guesses. Input the answer and the maxmimum number of tries, then repeatedly input the guesses, stopping when the user guesses the right number or they reach the maxmimum number of guesses. Use a while or a do-while to implement the repetition.