Hello everyone, i'm been practice C++ for a while just a new hobby in technology.

i start with mathematics with numbers and some cout, cin function

in other program like excel i can enter series of number and after that we can:

1. Sum them up
2. Divide them, multiple, list the highest number or smallest or whatever with number since they have some build-in F(x) and its very to use like writing in real life.

in C++ i've been experienced little much more trouble

#include <iostream>
void main()

well after this part i can declare a lot of variables but they are not so practical since the amount of number is fix (eg. 10 is 10 and no more). What i can do if i want to enter as many as i can and after that the mathematics will be later based these input numbers.

Any help will be so appreciated

Look up arrays, and loops
Accept numbers into an array using a loop find sum, avg, max, min etc.
Btw, Use int main() not void main().

Look up arrays, and loops
Accept numbers into an array using a loop find sum, avg, max, min etc.
Btw, Use int main() not void main().

I'm not allow to use array, teacher want me to think some of logical design

i'm thinking about counting with lot of variable, do you have any better idea?

logical design? wt does that mean?
Arrays are more logical than a 100 variables anyway.
Alternatives may be linked list?

If you need to do this without an array, then try this.

1. Declare variables to hold the sum, average( and a variable to hold the number of inputs, a counter, the user has enter in order for you to calculate the average), product and so on.
2. Initialize the sum to zero, the average to zero, and the product to one.
3. Use a do-while loop to do the necessary calculations. For example, as the user enters an input, add it to the sum, multiply it by the product, and increase the counter by one. Calculate the average only when the user has finished entering the inputs. You can get the average by dividing the sum by the counter variable.

Edited 4 Years Ago by cossay: n/a

This article has been dead for over six months. Start a new discussion instead.