Index Visual C++ and MFC Fundamentals
- Click Finish
- To add a header file, on the main menu, click Project -> Add New Item... In the Add
New Item – BusMath dialog box, in the Templates list, click Header File (.h).
Replace the content of the Name edit box with bmcalc and click Open - In the empty file, declare the following functions:
#ifndef _BUSINESSMATH_H_
#define _BUSINESSMATH_H_
double Min(const double *Numbers, const int Count);
double Max(const double *Numbers, const int Count);
double Sum(const double *Numbers, const int Count);
double Average(const double *Numbers, const int Count);
long GreatestCommonDivisor(long Nbr1, long Nbr2);
#endif // _BUSINESSMATH_H_
- To add a source file, on the main menu, click Project -> Add New Item... In the
Templates lis of the Add New Item – BusMath dialog box, click Source File (.cpp).
Replace the content of the Name edit box with bmcalc and click Open - Implement the functions as follows:
#include "StdAfx.h"
#include "bmcalc.h"
double Min(const double *Nbr, const int Total)
{
double Minimum = Nbr[0];
for(int i = 0; i < Total; i++)
if( Minimum > Nbr[i] )
Minimum = Nbr[i];
return Minimum;
}
double Max(const double *Nbr, const int Total)
{
double Maximum = Nbr[0];
for(int i = 0; i < Total; i++)
if( Maximum < Nbr[i] )