Remzi
2010-04-19 14:40:55 UTC
Code:
#include "stdafx.h"
#include
using namespace std;
double calcAverage(double sum, double count)
{
if (count > 0) {
return sum / (count * 1.0);
}
throw("calcAverage: Division by zero exception!");
return sum;
}
float calcAverage(double,int);
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"Input ten different floating numbers:";
double sum = 0;
double average = 0;
double numbers[25];
int count;
for (count = 1; count <=10; count ++)
{
cin>> numbers[count];
sum = sum + numbers[count];
}
average = calcAverage(sum,count);
cout<<"The average of the numbers in this array is " << average << ".";
return 0;
}
--------------------------
Output:
1>------ Build started: Project: FindAverage, Configuration: Debug Win32 ------
1>Compiling...
1>FindAverage.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>FindAverage.obj : error LNK2019: unresolved external symbol "float __cdecl calcAverage(double,int)" (?calcAverage@@YAMNH@Z) referenced in function _wmain
1>C:\Users\Amir\Documents\Visual Studio 2008\Projects\FindAverage\Debug\FindAverage.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Amir\Documents\Visual Studio 2008\Projects\FindAverage\FindAverage\Debug\BuildLog.htm"
1>FindAverage - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========