i dont know if this code is right because i'm trying to create a program that display the fibonacci value of a number with FUNCTIONS combining pass by the VALUE and pass by REFERENCE
please i needyour helpfor my preparation for my exam
#include <iostream.h>
void fibonacci(int, int&. int&);
int main(){ int num1=0, num2=1, num, fibo;
cout<<"Enter number of fibonacci value: ";
cin>>num;
if(num<=0)cout<<"invalid";
if(num==1)
cout<<"fibonacci value is"<<num1;
else if(num==2)
cout<<"fibonacci value is"<<num2;
else
cout<<"fibonacci value of<<num<<"is" <<fibo;
fibonacci(num,num1,num2);
}
void fibonacci(int num, int&num1, int&num2)
{ int ctr=2,fibo;
while(ctr<num)
{fibo=num1+num2;
num1=num2;
num2=fibo;ctr++;
}
return;
}
please help me with function,I;m really having a hard time to understand FUNCTIONS