SOURCE FILE: pythTrip.cpp



#include <iostream>
using namespace std ;

/* Should all parameters be reference parameters?
   Should all parameters be value parameters? 
*/

void GetNumbers (int & M_gn, int & N_gn) ;

void MakeTriple (int M_mt, int N_mt, 
                  int & S1_mt, int & S2_mt, int & S3_mt) ;

void PrintTriple (int S1_pt, int S2_pt, int S3_pt) ;

/* Some parameters are reference, other value ... why? */

int main (void)
{
   int M, N, S1, S2, S3 ;
	
	 /* Could we have a call like this?
               MakeTriple (2+3, 3, S1, S2, S3) ; */
	
   GetNumbers (M, N) ;
   MakeTriple (M, N, S1, S2, S3) ;
   PrintTriple (S1, S2, S3) ;
   return 0;
}

void GetNumbers (int & M_gn, int & N_gn) 
{
  cout << "\nEnter two positive integers M, N with M > N: " ; 
  cin  >> M_gn >> N_gn ;
}

void MakeTriple (int M_mt, int N_mt, 
                  int & S1_mt, int & S2_mt, int & S3_mt) 
{
   S1_mt = M_mt*M_mt - N_mt*N_mt ;
   S2_mt = 2*M_mt*N_mt ;
   S3_mt = M_mt*M_mt + N_mt*N_mt ;
}

void PrintTriple (int S1_pt, int S2_pt, int S3_pt) 
{
   cout << "\nThe triple is S1: " << S1_pt << ", S2: " << S2_pt
        << ", S3: " << S3_pt << endl ;
   cout << "\nS1 squared is: " << S1_pt*S1_pt << ", S2 squared is: " 
        << S2_pt*S2_pt << endl ;
   cout << "\nThe sum of the squares is: " << (S1_pt*S1_pt) + (S2_pt*S2_pt) 
        << endl ;
   cout << "\nS3 squared is: " << S3_pt*S3_pt << endl << endl ;
}