I solving the problem of fibonacci series in c.It was going well.When I give input n=48 it show negative number. First 47 numbers shows correct answers.After n=47, it is showing error...what is bug in the code? I set 0 and 1 as first two default numbers of the series.
#include <stdio.h>
//Find Fibonaaci Numbers .......
int main(){
int s1,s2,c,n;
s1=0;
s2=1;
c=3;
printf("Enter a number ");
scanf("%d",&n);
printf("1. %d \n",s1);
printf("2. %d \n",s2);
for(c=3;c<=n;c++){
s2=s1+s2;
printf("%d. %d \n",c,s2);
s1=s2-s1;
}
}