plsss sayy what wass the error

+1 vote
asked Sep 23 by (260 points)
#include<stdio.h>

int fibonacci(int y)
void main()
{
    int n;
    printf("enter a number :n");
    scanf("%d",&n);
   int x= fibonacci(n);
   printf("%d",x);
}

int fibonacci(int y)
{
    int first=0;
    int second=1;
    if(n==1)
    {
       return first;
    }
    else if(n==2)
    {
        return second;
    }
    else
    {
        return fibonacci(n-1)+fibonacci(n-2);
    }

3 Answers

0 votes
answered Sep 23 by anonymous
check your semicolons and statements like return also you else is not written neatly try to arrange it
0 votes
answered Sep 23 by (140 points)
#include<stdio.h>
int fibonacci(int y);
void main()
{
    int n;
    printf("enter a number :n");
    scanf("%d",&n);
    int x= fibonacci(n);
   printf("%d",x);
}

int fibonacci(int y)
{
    int first=0;
    int second=1;
    if(y==1)
    {
       return first;
    }
    else if(y==2)
    {
        return second;
    }
    else
    {
        return fibonacci(y-1)+fibonacci(y-2);
    }
}
0 votes
answered Nov 7 by (1,070 points)
# fibonacci series

a=int(input('enter the number upto u want: '))
first=0
second=1
for i in range(a):
    print(first)
    temp=first
    first=second
    second=temp+second
output:                               @python
enter the number upto u want: 10
0
1
1
2
3
5
8
13
21
34

use this
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...