Programming-Cpp

Tasks studies - laboratory


Project maintained by dawidolko Hosted on GitHub Pages — Theme by dawidolko

Colloquium 4

Create a directory whose name will contain your name and surname. In the directory created in this way, place the solutions under the names taskl, task2, etc. Do not use library functions to solve the tasks, except for input/output operations.

Task 1.

Write a program that reads two rational numbers from the standard input and prints their average on the standard output.

Task 2.

Write a program that reads a rational number from the standard input and prints a number with an absolute value greater by one than the absolute value of the entered number, but with the opposite sign to the entered number.

Task 3.

Write a program that calculates the value S=sum i=1 to k (i+3)/(i^2) The value of the natural number k is entered from the keyboard.

Task 4.

Write a program that, for the natural number n entered by the user, calculates the nth term of the sequence given by the formula:

an = 3 when n = 1 or n = 2 otherwise
2(an-2)+5(an-1)+1 otherwise

Use the function for this purpose.

Task 5.

Write a program that shifts all elements of an array by one to the right (so that the value of the element with index O is in the element with index 1, the value of the element with index 1 is in the element with index 2, and the value of the element with index n - 1 is in the element with index 0). The value of the array size n>1 and the elements of the array are provided by the user.