Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls


Maximum = Nbr[i];
return Maximum;
}

double Sum(const double *Nbr, const int Total)
{
double S = 0;

for(int i = 0; i < Total; i++)
S += Nbr[i];

return S;
}

double Average(const double *Nbr, const int Total)
{
double avg, S = 0;

for(int i = 0; i < Total; i++)
S += Nbr[i];
avg = S / Total;

return avg;
}

long GreatestCommonDivisor(long Nbr1, long Nbr2)
{
while( true )
{
Nbr1 = Nbr1 % Nbr2;
if( Nbr1 == 0 )
return Nbr2;

Nbr2 = Nbr2 % Nbr1;
if( Nbr2 == 0 )
return Nbr1;
}
}


  1. To create the library, on the main menu, click Build -> Build BusMath

  2. To prepare a test for a console application, display the New Project dialog box. In the
    Project Type, click Visual C++ Projects and, in the Templates list, click Win32
    Project. In the Name edit box, type BusMathTest1 and press Enter

  3. In the Win32 Application Wizard, click Application Settings. In the Application
    Type section, click the Windows Application radio button. In the Additional Options
    section, click the Empty Project check box

Free download pdf