Lab Dec 1

  1. Write a function sum_sqr(n) that has oen integer parameter, the function finds and returns the following sum: 1*1+2*2+...n*n. Write a program that randomly generates 10 integers between 5 and 10. For each integer the program uses function sum_sqr to find the sum of squares.
  2. Write a program that reads a sequence of positive integers. The first negative or zero terminates the input. Store inputs in the list. The program prints ONLY last digit of each number in reverse order of the input. Each last digit will be printed on the separate line.

    For example, if the input is 14 3415 231 6514 32999 -1. The output should be:
    9
    4
    1
    5
    4

  3. Write a program that randonly generates list of integers in specific range and finds sum, average, max and min, and percentage of 0's in the list.
  4. Write three functions:

    Write a program that reads a sequence of positive integers, the first non-positive integer terminates the input. Assume that the amount of input numbers is even. Starting from the first input number, consider the pair of inputs as value of x and the value of n and find the approximated value of e^x using n terms of the given formula. The program prints the results on different lines printing the value of x and the value of n as well as the value e^x. Use function valueExp to calculate the approximate value.

  5. Write a function dieRes () that rolls the six-sided die one time using random number generator and returns the value between 1 and 6 that indicates the number that was rolled in one roll. Write a program that reads one integer, that indicates the amount of times that the six-sided die will be rolled in the program. The program will calculate and return the frequencies of appearance of integers between 1 and 6.