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.


Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.