-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.c
99 lines (82 loc) · 1.02 KB
/
input.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
int square(int x) {
int ret;
ret = x * x;
return ret;
}
int sum(int a, int b) {
int ret;
ret = a + b;
return ret;
}
int fibo(int n) {
if(n == 0) {
return 0;
}
if(n == 1) {
return 1;
}
int ret;
ret = fibo(n-1) + fibo(n-2);
return ret;
}
int factorial(int n) {
if(n == 0) {
return 1;
}
int ret;
ret = factorial(n-1);
ret = ret * n;
ret = ret;
return ret;
}
int main() {
int a, b;
// a = 10;
// b = 3;
int sumval;
// sumval = sum(a, b);
int sqval;
// sqval = square(b);
int total;
// total = sumval * sqval;
int n;
n = 5;
int fn;
fn = fibo(n);
println(fn);
int fact;
fact = factorial(n);
println(fact);
int series_sum;
series_sum = 0;
int i;
for(i=0; i<n; i++) {
series_sum = series_sum + i;
}
println(series_sum);
int p, q, r;
p = 10;
q = 5;
r = 9;
if(p > q) {
if(p > r) {
println(p);
return 0;
}
else {
println(r);
return 0;
}
}
else {
if(q > r) {
println(q);
return 0;
}
else {
println(r);
return 0;
}
}
return 0;
}