Lab 8 Answer Sheet

This lab is to be worked in a group.


Name: ________________________     Netid: _______________    Section: _______

Name: ________________________     Netid: _______________    Section: _______

Name: ________________________     Netid: _______________    Section: _______
 

Part I

1. Rewrite the program using a do-while loop. Fill in the blanks below with your code. Try compiling and running both versions of the loop to make sure they behave exactly the same.


  /* You may not need to use all the blanks below. */
  #include <stdio.h>
#include <time.h> /* library containing the "time" function */
#include <stdlib.h> /* library containing the "rand" function */

int main(void)
{
int N;
int Total = 10;
int counter = 1;



printf("Enter a number: ");
scanf("%i", &N);


________________________________________________________________________________


	________________________________________________________________________________



	________________________________________________________________________________



	________________________________________________________________________________



	________________________________________________________________________________

printf("\n");
return 0;
}


2. Rewrite the program using a for loop. Fill in the blanks below with your code. Try compiling and running both versions of the loop to make sure they behave exactly the same.



  /* You may not need to use all the blanks below. */
  #include <stdio.h>
#include <time.h> /* library containing the "time" function */
#include <stdlib.h> /* library containing the "rand" function */

int main(void)
{
int N;
int Total = 10;
int counter = 1;



printf("Enter a number: ");
scanf("%i", &N);

	________________________________________________________________________________ 


	________________________________________________________________________________



	________________________________________________________________________________



	________________________________________________________________________________



	________________________________________________________________________________

printf("\n");
return 0; }

Part II


     3. TA's signature _____________________________________________________________  
  1. What is the best strategy to win the guessing game?
     

    _________________________________________________________________________________________________________________________________

Part III

  1. TA's signature ________________________________________________________________