Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,624 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,053 people online right now. Registration is fast and FREE... Join Now!




Class implementation + Arrays

 
Reply to this topicStart new topic

Class implementation + Arrays

antdog49
post 29 Mar, 2006 - 12:05 PM
Post #1


New D.I.C Head

*
Joined: 29 Mar, 2006
Posts: 1


My Contributions


I am learning C++ and I have an assignment:

Write an interactive C++ program that prompts the user for ten (10) real numbers and calculate the sum, average, and prints the result. Hint: you may use an array to store the data.

Program requirements:
- The program must contain a class in which all the required private and public identifiers and the following functions must be defined.
- The program must contain three or more functions using parameters. These functions should read the data, calculate the sum, find the average, and print the results.


My question is how do I write an array that asks the user to input a number 10 times? Do I put this array in the class or the main porgram?
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 29 Mar, 2006 - 01:12 PM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


You'd put the array in the class. As for prompting the user, it is simply a matter of using a loop...
CODE

int num[10];
for(int i=0;i<10;i++)
{
  cout<<"Please enter an integer:"<<endl;
  cin>>num[i];
}

After the loop, your array will be loaded.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 03:24AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month