C
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
#include<stdio.h>
#include<math.h>
int main()
{
int n, i,third;
int f=0, s=1;
printf("enter the position to print the fib number: ");
scanf("%d",&n);
if(n==1)
{
printf("%d",f);
}
else if(n==2)
{
printf("%d",s);
}
else
{
for(int i=3; i<=n; i++)
{
third=f+s;
f=s;
s=third;
}
printf("%d",third);
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run