HW14
COP-3223H
Setup
See HW7's Setup for how to prepare for performing and submitting your homework.
Homework file names
- hw14-1.c
- hw14-2.c
Questions
(
hw14-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.
- (
hw14-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.
Submission
See HW7's Submission instructions for adding, committing, and pushing your homework to the assignments' repo.
Self-check
See HW7's Self-check for instructions on checking what you have submitted to the remote grading repository.