You can enter c in main then make it available to all the functions exept second and that will take care of it. see below:
Code:
//---------------------------------------------------------------------------
//#include <vcl.h>
#include <iostream.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//#pragma argsused
int first( int a, int c );
int second( int b, int a );
int third( int b, int a, int c );
int fourth( int a, int b, int c );
int main(int argc, char* argv[])
{
int a;
int b;
int c;
//send this input to other functions
cout<< "Enter a number (a): ";
cin >>a;
cout<< "a = " << a << endl;
cout << "Enter another number (b): ";
cin >> b;
cout<< "b = " << b << endl;
cout << "Enter another number (b): ";
cin >> c;
cout<< "c = " << c << endl;
//get this back from other functions
cout<< "\nFirst returns a*c= "<< first( a, c ) << endl;
cout<< "\nSecond returns a*b= "<< second( a, b ) << endl;
cout<< "\nThird returns " << second( a, b ) << "*" <<
first( a, c ) <<"= " << third( b, a, c ) << endl;
cout<< "\nFourth returns " << first( a, c ) << "*" << second( a, b )
<< "*" << third( b, a, c ) << "= " << fourth ( a, b, c ) << endl;
return 0;
}
//Functions
//simple a times c
int first (int a, int c)
{
return a*c;
}
//simple a times b
int second (int a, int b)
{
return a*b;
}
//first times second
//requires value for "int c"
//to be entered twice???
int third(int b,int a, int c )
{
return ( first( a, c ) * second( a, b ) );
}
//first times second times third
//requires value for "int c" to be entered
//four times???
int fourth(int a, int b, int c )
{
return ( ( first( a, c ) * second( a, b ) ) * third( b, a, c) );
}