CME 112- PROGRAMMING LANGUAGES II WEEK-1 LAB QUESTIONS 1) Write statements that assign random integers to the variable n in the following ranges: 1<= n <= 2 1<= n <= 100 1000 <= n <= 1112 -3 <= n <= 11 exponent 2) Write a function integerPower(base,exponent) that returns the value of base For example, integerPower( 3, 4 ) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Do not use any math library functions. 3) Write a recursive function for the problem given in question “b” above. The recursion step would exponent use the relationship base exponent–1 = base * base and the terminating condition occurs 1 when exponent is equal to 1 because base = base Home Work Write a C program that plays the game of “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. The program then types: The player then types a first guess. The program responds with one of the following: If the player’s guess is incorrect, your program should loop until the player finally gets the number right. Your program should keep telling the player Too high or Too low to help the player on the correct answer.
© Copyright 2026 Paperzz