0
How to create function with 2 parameters to print fibonacci?
I have struggle to create this function to return this fibonacci use looping in c++ 0 1 1 2 3 5 8 13 21 34 55 89
7 ответов
+ 3
can u write a function that adds two numbers given as parameters?
+ 2
let's start by cleaning up the unnecessary cout and cin n & m above
+ 1
i create this code. please correct me
#include <iostream>
using namespace std;
int main()
{
int n, m, t1 = 0, t2 = 1, t3 = 0;
cout << "eter colom: ";
cin >> n;
cout << "enter row: ";
cin >> m;
for(int j=1; j<=3;j++){
for (int i = 1; i <= 4; i++)
{
if(i == 1)
{
cout <<" "<< t1;
}
if(i == 2)
{
cout << t2<<" ";
}
t3 = t1 + t2;
t1 = t2;
t2 = t3;
cout << t3 << " ";
}
cout<<"\n";
}
return 0;
}
+ 1
a good start👍
now we need it as a fuction
0
ok... step by step
uf u have the first 2 numbers, which is the next one?
0
I still stuck on it 🥴
0
here is my code in Perl - maybe you will understand
https://code.sololearn.com/cSB0ZKlT7fMR/?ref=app