i'm working on a program that allows the user to enter 10 numbers those numbers are stored into a array, once stored into a array the average of those ten numbers will be processed in the function. i have the code but i running into errors along the way. i know i look bad but if any one can help me thank you.
#include "stdafx.h"
#include <iostream>
using namespace std;
double theav( double total[], int to_count) //this is the function that calculates the average of the numbers that the user has inputed
{
int x ; // set the x varuable to int
double sum = 0; //sets the sum as double and alost to equal 0
for (x = 0; x < to_count; x++) //for loop x
{
sum = 10 / total[x]; // calculates the average
}
return sum/10;
}
int main ()
{
int sum= 0; // declares sum as integer
double average=0; // declares average as double
int total [10]; //declares total as integer
//declares theav as double
double x ; //declares total as integer
x = theav();
for (x = 0; x<10; x++) // loop for array thotal[10] this stores the numbers for the array
{
cout << "enter a number:" << (x+1) <<endl;
cin>> total[x];
#include <iostream>
usingnamespace std;
double theav( int total[], int to_count) //this function calculates the average
{
int x ; // set the x varuable to int
double sum = 0; //sets the sum as double and alost to equal 0
for (x = 0; x < to_count; x++) //for loop x
{
sum += total[x]; // calculates the sum
}
return sum / to_count; // calculates the average
}
int main ()
{
double average=0;
int total [10];
int x ;
for (x = 0; x<10; x++) // loop for array thotal[10] this stores the numbers for the array
{
cout << "enter a number:" << (x+1) <<endl;
cin>> total[x];
}
average = theav(total,10);
cout << "The Average is " << average; // shows the average
return (0);
}
thanks shredded i'm getting a error. i'm using Microsoft visual C++ 2010 express.
and when i run the program i'm getting this error.
1>------ Build started: Project: final project, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\First\Documents\Visual Studio 2010\Projects\final project\Debug\final project.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
is there a syntax error that i might have overlooked or is it something else
Im not sure if it will work but if you create a new (console App) project
and copy and paste the code into the new file, and try to compile from there.
It runs perfectly for me. I think you need to change some settings for the project or something like that, I've encountered the error before in Microsofts thingies. You need to choose if it's a console or windows project or something like that I think.
hey guys thanks for the help if another person says it work i'll believe them. and if some one can, can you post the results of the program so i can see what it looks like. the reason is that i tried changing the properties and i this is what i got.
1>------ Build started: Project: final project, Configuration: Debug Win32 ------
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(332,9): error MSB4030: "main" is an invalid value for the "NoEntryPoint" parameter of the "Link" task. The "NoEntryPoint" parameter is of type "System.Boolean".
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========