-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.c
60 lines (59 loc) · 1.13 KB
/
error.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
float fib1(int n,float c)
{
int i,t1,t2,next;
i = c;
t1= 0;
t2= 1;
next = 0;
write("Fibonacci Series: ");
do{
write(t1);
write(", ");
next = t1 + t2;
t1 = t2;
t2 = next;
i = i+1;
}while(i>n);
return c;
}
void fib2(int n)
{
int t1,t2,next;
t1= 0;
t2= 1;
next = 0;
write("Fibonacci Series: ", t1,", ", t2,", ");
next = t1 + t2;
while(next <= n)
{
write(next);
write(", ");
t1 = t2;
t2 = next;
next = t1 + t2;
}
}
int main(){
writeln("This program will print Fibonacci sequence!Have fun!");
writeln("1:Get Fibonacci Series up to n number of terms");
writeln("2:Get Fibonacci Sequence Up to a Certain Number");
writeln("Please choose 1 or 2: ");
int j,k;
float m;
m = 0.1;
readln(j);
//int k;
if(j==1){
writeln("Please enter the number of terms:");
readln(k);
j=fib1(k,m);
fib1(k);
}
else{
writeln("Enter a positive number:");
readln(k);
fib2(k);
m = fib2(k);
}
return 0;
}