-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathcs1_lab03.Rmd
More file actions
30 lines (24 loc) · 1.17 KB
/
cs1_lab03.Rmd
File metadata and controls
30 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
number: 3
course: Computer Science 1
material: Instruction 3
---
## 1.
Write a program which checks if arbitrary segments $a$, $b$ and $c$ can be used to build a triangle.
The program then should find what kind of a triangle it is (equilateral, right-angled, isosceles).
Variables $a$, $b$ and $c$ should be declared as global and their values should be read in an appropriate function.
## 2.
Add to the program a function which finds the longest side of the triangle.
The length should be returned as the function return value.
Call the function in main function and print the result.
## 3.
Write a program calculating value of the factorial of n.
Use the `for` loop and do not use a function.
Find the maximum value of $n$ for which the result can be stored using int type without truncation.
## 4.
Modify the program from previous point in such a way that the main function contains only calls to three functions: `ReadN()`, `Calculate()` and `PrintN()`.
Variable `n` can be declared as a global one.
## 5.
Modify the program in such a way that variable $n$ is declared as a local variable inside the main function.
## 6.
Modify program in order to use `while` loop instead of `for` loop.