Test 1
You have two tasks to do. Your teacher will give you your personal test number .
Upload your files here after completing tasks.
Student 1
Task 1.
To do: The price of 1 kg of sweets is entered (an integer number). Create a function with one argument to print the cost of 1.2, 1.4,…, 2 kg of sweets. Use for loop.
Note: the signature of the function:
void printPrice(int price)
{
// …
}
Expected output:
Please, enter the price of 1 kg:
>>>63
Result:
75.6 88.2 100.8 113.4 126
Task 2.
To do: Create a function to calculate a multiplication of even integers in the interval [10;20] (10 * 12 * 14 * 16 * 18 * 20). Make the task using a while loop. Create a multi-file project to solve the task: main.cpp, implementation.cpp, header.h.
Note: The signature of the function must be:
void findMult(int & a, int & b){ … } |
where a = 10 and b = 20
Expected output:
Result:
9676800
Student 2
Task 1.
To do: The price of 1 kg of sweets is entered (an integer number). Create a function with one argument to print the cost of 1, 2, 3…, 10 kg of sweets. Use for loop.
Note: the signature of the function:
void printPrice(int price)
{
// …
}
Expected output:
Please, enter the price of 1 kg:
>>>63
Result:
63 126 189 252 315 378 441 504 567 630
Task 2.
To do: Create a function to calculate a sum of odd integers in the interval [21;33] (21 + 23 + 25 + 27 + 29 + 31). Make the task using a while loop. Create a multi-file project to solve the task: main.cpp, implementation.cpp, header.h.
Note: The signature of the function must be:
void findSum(int & a, int & b){ … } |
where a = 21 and b = 33
Expected output:
Result:
157
Student 3
Task 1.
To do: Two integers A and B are entered (A<B). Create a function with two arguments to print the squares of all integers between A and B in ascending order and including these numbers themselves. Use for loop.
Note: the signature of the function:
void printSquares(int a, int b)
{
// …
}
Expected output:
Please, enter two numbers A and B:
>>> 4 >>> 13
Result:
16 25 36 49 64 81 100 121 144 169
Task 2.
To do: Create a function to calculate a sum of integers in the interval [-5;10] with a step=3 (-5 + -2 + 1 + 4 + 7 + 10). Make the task using a while loop. Create a multi-file project to solve the task: main.cpp, implementation.cpp, header.h.
Note: The signature of the function must be:
void findSum(int & a, int & b){ … } |
where a = -5 and b = 10
Expected output:
Result:
15
Student 4
Task 1.
To do: Two integers A and B are entered (A<B). Create a function to calculate a value of the function z(x) = 2x-2 for all x varying on the interval [A, B]. Use for loop.
Note: the signature of the function:
void printFunc(int a, int b)
{
// …
}
Expected output:
Please, enter two numbers A and B:
>>> 3 >>> 14
Result:
4 6 8 10 12 14 16 18 20 22 24 26
Task 2.
To do: Create a function to calculate a multiplication of integers in the interval [-5;7] with a step=3 (-5 * -2 * 1 * 4 * 7 ). Make the task using a while loop. Create a multi-file project to solve the task: main.cpp, implementation.cpp, header.h.
Note: The signature of the function must be:
void findMult(int & a, int & b){ … } |
where a = -5 and b = 7
Expected output:
Result:
280