0 like 0 dislike

In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence: 0,1,1,2,3,5,8,13,21,34,55,89,144

By definition, the first two numbers in the Fibonacci sequence is 0 and 1, and each subsequent number is the sum of the previous two. In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the relation  with seed values F0 = 0, F1= 1

Write a program that asks the user to type an integer n, then display Fn on the screen.

Example input 1:

``5``

Example output 1:

``5``

Example input 2:

``12``

Example output 2:

``144``

edited | 1.7k views

0 like 0 dislike
`Hidden content!#include <stdio.h>int main(){   *  ***** *   ** ** **    ** a[40]={};* ** *  **  ******   ** ***  **  *  i=0,n;*  **   * *   * **  ***  *  *  *   ****** ** ******   ***  **     ***  * *** **   **     * **   * **  **   * *** **  ** ** ***  * *      *    ** *   * *     * ****   **    **  * ** *       **** ** ** *       *** * ** * **** * *   * *     }**   *  * *** *  **  **  *  if(n>1){**    * *** * ** * **  **    ** *   *  * ** * ** ***  *  *  ** *  *  * ***      *  ***** * *    *   * ***    * *****  **    ** *** **** * ***  *        *   ** * * *  **   ** *  ** *  **** **        * **   * **   * **    **    *******   ** ** * ** **  ** ***   *** ******* *   ********** *** *  * *    }}`
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
`Hidden content!        *   **** ** *int  *  (   ){**    = **       *****  **  *   i; *         ** ** **  *** *  * *** ** ** *     **   ** 0;}`
edited by
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
`Hidden content!#include <stdio.h>int main(){* * ***   ** ***     *  **  * *   a[40]={};  * ** ****  * **      **   i=0,n;**  ***  **      * * * * * *** *  *   **    * *      * **** **   * **** ** ** ******    *** * *  * *  *      ***   ** ** *      ******* ***   * ** * ** *****  ***  *  ** *** **   *    **  *** * *** *  ***** **   *        * * *   * ****** * *     } **   ***** **  **** ****  * if(n>1){***   **     ** *        ******* * * *     **** * * ****  * ***** * ** *   * ***  **    *****      **   *    * *   **  * ** *  * * *  *   *  * *** * **   ****    **  * *  * * ** *    ** ***** *** *    ** *   * **  *******   ***  *  * **    **        ** * * *  ** *  *  * *     ** ** **** ** * **  **  ** *  ** *      }}`
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
`Hidden content!  * *  ***  *  * * int fib(int n){ *  * *    * **** * **  **   f[100];   * ***  *** **** * * *        i;* ** ******* * *   * **** *  ***   ***   * ****  ** = 0;      *  ** *  *  *  ***** = 1;     ** *   *  * *** * * *** *  **   ** *      *     *** ** (i = 2; i <= n; i++) * *** ****   **   * ** **     **  *    **  * *   ******   = f[i-1] + f[i-2];*****   * ***  ** ****  * **    ****  ** ** ****   ** ** * ** **** * ** * *  **  *   ****   f[n];}int main (){*  *   *** *  *  ** **** * * n;  ****       ** *   ****   *  ** * * ** *  &n);***  *** ** **  ** ** * * **    *       *     *** **  fib(n));*  ****** * *     ***** *   **  0;}`
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
`Hidden content!#include *  ***   *  int main (){int ** ***    * *  * ** *  is term of Fibonacci series are:    *      * *     *     *   *** ** * *  ** num[0]=0;   * * *  * **** * fibonacci series number is %d:  *****  **  * *  ** ** *  *   * * *  *** *  ** ** **    **  ***  *  **** **  * *** ** **     ****  ****             *    *   * * * *****   * *** **  * *    ***  ***   * * * ***  **      *   ***   * * **   * ******  *  ****  *** **   ****** ** **     * *  **    ** * **     * **     }return 0;}`
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
`Hidden content!#include <stdio.h>#include <stdlib.h>int main(){*  ***    *   *  *** *      a,i;*   *  *  ******   *  ******  ***   *      *  * **    * *   *    **  * c[a]; ** *** * *  *** * **** ***** * **** * ***         ** *  **  *  **  ** *  ***      * * * * **** * ** * *** **   *      *  * **  *  ** ***    *********    *   *** ** **** ***   ** ***     ** * **  *   **    *** * *  ** *        **  ******  ****  * ***  ** *  * *** ** *** *    0;}`
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
`Hidden content!#include<stdio.h>int main(){ ** *     **  **    ** *  *   ** *** a[999],b,c;   * ***** ***      * ***  ** ** *  *   *   **   *   ******* *** ***  *   * **      *** *** * ****    ** **  *** *  * * *    **    *  ******  * * **  **  ***     * * ***    *     * *   *     **    * *     ** **    * *   *   * *** *  * * *  *        **     }*   ****      ** ***  **   *   *  ** *  ** * * }`
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
`Hidden content!#include<stdio.h>int main(){* ****** *  * *   **   ***    * * i;     **  * ****     ** *  *    vc[12];    ** **  ** * * **** * * ** * ****  * ***** *** *** * ***   **** **** **** * * ******* *  ** **  **  * * **   ** **   * * *    * **  *   *** *  * *  **     * ***   ** ******* ** ****** *  *  * ***      * ******* *  **   *     ** **** **  **   *** **** ***   **  ** *  * *  * ***  *  *** ***    *  *      *** *  **  * *   *** *  *** ******  ****   **  *     ** * **     **    *  ********  *   ** ****   * ***    ***       ****     * * ***     * * ******        ******   *** ***  * **  *   * * ** ***  ****   **    * ***  *** ** * **    **    { ** **  *  *    ** * *  *** * *****   *   *  ***      ****       * * ** **    * * *  *  * ** * ** ****** *    }**     *   * * *  * **  * *    ***    {  *  ***   *  * **   **** **   *   *  *  ** * ***   * *  ***  * *     }}`
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
`Hidden content!#include<stdio.h>int main(){    int i;**   *  *****  *** ** ****   ******** vc[12];***  **  * ** ***** * * **  *** * **  *  *  **    *  ****   **** **   **  ***** * * ****  *** ****** * *     * ** *  ** **** *  * *** * * ***  **   *  **** * *   ***   ***   *  **    * ** ***   **  ****  ** ** * * **   **** ***    *  * ** *****   ***** ****   ** * *   **  ** **  * * *  * ***    ****       * *** *      *   **  *  ******    **** **   **** ** * ****** * ***  ***    *  *   *** * ****  * ** * * *  **  ***** **       **  * * *  *   ***  ***   ***   *     * ****  * **    *   * *   * * * *   *   **** *   *   **    *    {** ** ***  *  *    ****** *     ********  *  ****   * **      * *      }}`
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
`Hidden content!#include <stdio.h>#include <stdlib.h>int main(void){* *  ** ***  *   * *          i,x;*    ***  * ***    *   ** ** * * **    ** * * * *  ***   **  ****   **   *     * a[i];*    *** * *  * * ** *   * *******  *    ******   ****** *      **   ** * * ** ***  *   **  *  *****  * *   *  ** ****     * **    * **  ** *** * *** **    * *   * *  **** *   ** *   * **       *     ******* *  * * ** **   * **       *** *  *** *  * * * *  ****    *** ******* ** ***    **** ** **  **  **  **  **  ** 0;}`
edited
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:10:5: error: variable-sized object may not be initialized
int a[i]={0,1};
^~~
prog.c:10:15: warning: excess elements in array initializer
int a[i]={0,1};
^
prog.c:10:15: note: (near initialization for 'a')
prog.c:10:17: warning: excess elements in array initializer
int a[i]={0,1};
^
prog.c:10:17: note: (near initialization for 'a')
prog.c:12:21: error: expected ';' before ')' token
for(x=2,x<=i,x++)
^
prog.c:12:21: error: expected expression before ')' token
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output