954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ : Calculating the average value of an array

Hello, I'm new to both C++ and these forums. What I'm trying to do is calculate the average of all values contained within an array. Is there a simple command that can do this for you, or does one need to set up some kind of loop? Any help or suggestions would be greatly appreciated.

Thanks

Maxxpower
Newbie Poster
1 post since Sep 2006
Reputation Points: 13
Solved Threads: 0
 

If you are just starting, you'll probably want a loop (the STL does have a function to do [edit]summing[/edit], but I'm guessing that if you posted this question then you need to start further back). The average would be the sum divided by the total number of items.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

It would really benefit to you if you could read on some introductory material to the C++ programming language or some newbie book like "Sams Teach yourself C++ in 21 days" to get the hang of the subject.

This forum will help you definately if you get stuck in your coding attempt anytime but before that you must know the basics of the language and must have dedicated some time and research on it.

Anyways, welcome to the coding hell.

PS: Long time no see Mr. Dave. Welcome back.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You