#include <conio.h>
#include <iostream>
using namespace std;
void newLine();
//The function prototype does not need to know the exact variables, it only needs to know the data types
void Results(int, int &, int &, int &, int &, int &, int &, int &);
void main ()
{
char name[35] = "";
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
int h=0;
cout << "Enter your name: ";
cin.getline(name, 35);
newLine();
cout << "Hello " << name;
newLine();
newLine();
cout << "Enter a number: ";
cin >> a;
newLine();
cout << "Your Fibonacci Series is: ";
newLine();
newLine();
Results(a, b, c, d, e, f, g, h);
_getch();
}
void newLine()
{
cout << "\n";
}
//Here one needs to put the value of the exact variables
void Results(int a, int &b, int &c, int &d, int &e, int &f, int &g, int &h)
{
h=a-1;
b=a+(a-1);
c=a+b;
d=b+c;
e=c+d;
f=d+e;
g=e+f;
cout << " " << b;
cout << " " << c;
cout << " " << d;
cout << " " << e;
cout << " " << f;
cout << " " << g;
_getch();
}
In this tutorial, the tutor says about the use of '&' and about memory address passing etc, but I really could not get the point. My simple code works exactly the same with or without the '&'. Please help me understand the use of '&'.
P.S. I am just a beginner

New Topic/Question
Reply




MultiQuote









|