Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

plsss sayy what wass the error

+1 vote
asked Sep 23, 2019 by Gopi Jonnalagadda (250 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, 2019 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, 2019 by dev-elixir (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, 2019 by dheeraj (1,090 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.
...