Function that returns a integer value and displays it

Is it possible to create a function that can both return and display a value. I was trying to make a program that computes and prints terms of the Fibonacci series using a recursive function.
1
2
3
4
5
int Fun(int Ivalue)
{
cout << Ivalue;
return Ivaluel;
}
Last edited on
Find the bug! :-)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int fibb(int n1 = 1, int n2 = 0)
{
    cout << n1;
    cin.get();
    return fibb(n1+n2, n1);
}

int main()
{
    fibb();
}
Last edited on
Topic archived. No new replies allowed.