Why am i not able to print 47th fibonacci number correctly?

前端 未结 4 1611
梦如初夏
梦如初夏 2021-01-29 16:40

I am using 64 bit operating system ,then also i am not able to print 46th fibonacci number correctly which is less than 4 billion.

#include
#inclu         


        
4条回答
  •  没有蜡笔的小新
    2021-01-29 16:59

    You have to use long long as your data type of the array. because You are going to store out-range numbers of the integer range.(-2,147,483,648 to 2,147,483,647) And declaration of int i should be before the for loop.

    #include
    
    int main(void)
    {
    
        int n=50;
        long long array[n];
        array[0]=0;
        array[1]=1;
        printf("%lli\n",array[0]);
        printf("%lli\n",array[1]);
        int i;
        for(i=2;i

提交回复
热议问题