3333
|
} |
3434
|
void PrintFunction ()
|
3535
|
{ |
3636
|
// Simply display the following text when called.
//return no value to the caller |
3737
|
cout<<"\nWhen PrintFunction is called "<<endl;
|
3838
|
cout<<"It returns nothing because it of a void function.
However this message is displayed once it is called"<<endl;
|
3939
|
} |
4040
|
// When called function DFunction() receives nothing .
// It will however return a value it will calculate basing on its local variables |
4141
|
double DFunction()
|
4242
|
{ |
4343
|
double p = 12.122;
|
4444
|
double q=2.0;
|
4545
|
cout<<"\nAlthough function DFunction does not receive data when called "
|
4646
|
<<"\nIt returns a value"
|
4747
|
<<"\nto the calling function..."<<endl;
|
4848
|
// return the result to the caller... |
4949
|
return p/p;
|
5050
|
} |
5151
|
int IntFunction(int a,int b)
|
5252
|
{ |
5353
|
// receive data, works on it and returns the result to the caller |
5454
|
a=2;
|
5555
|
b = a * 100;
|
5656
|
int c=b/4;
|
5757
|
cout<<"On completing the calculation function it.. "
|
5858
|
<<"\nreturns result to the calling function
which in is this case is main()\n"<<endl;
|
5959
|
// now return the data stored in c to main () |
6060
|
return c;
|
6161
|
} |
6262
|
// Function myName receives the names and displays on the screen instead of returning a value |
6363
|
void myName(string fname)
|
6464
|
{ |
6565
|
// receive something but return nothing... |
6666
|
string firstName = fname;
|
6767
|
cout<<"\nFunction myName receives the name from the caller."<<endl;
|
6868
|
cout<<"but does not return any value to the caller, rather..."<<endl;
|
6969
| cout<<"Then it processes and displays name as "<<firstName<<endl;
|
7070
|
} |
No comments:
Post a Comment