Need help with a simple program

Hey everyone! I need help with this program. I'm a beginner. Here is the assignment.

To get the average of a series of values, you add the values up and then divide the sum by number of values. Write a program that stores the following values in five different variables: 28, 32, 37, 24, and 33. The program should first calculate the sum of these five variables and store the result in a separate variable names sum. The, the program should divide the sum variable by 5 to get the average. Display the average on screen

If someone can show me how they coded this. I would greatly appreciate it!!
Do you know the structure of a C++ Program? Do you know how to declare variables? Mathematical operators?

It is the unspoken rule around here not to give the answer to homework questions. However, I can help you with a particular thing. So, tell me what you know, what you have tried, and I will give some pointers. (Not literally :D)
Last edited on
would be glad to help with something more specific
First, declare variables. Then have you got knowledge of what a "C++ Formula looks like? Or know about one?"
I would declare an array of int's and store the input in that and then iterate over the array etc...
Can someone make this program i can't.

2. Write a program called ShapeCalculators that does the following:

a. Asks the user for the base and height of a triangle
b. Asks the user for the height and width of a rectangle
c. Asks the user for the radius of a circle
d. Outputs the area of each shape in the following format:

Shape Area
Triangle ###.##...
Rectangle ###.##...
Circle ###.##...

Note: Use the fraction 22/7 to approximate pi.
@Nalaxer14 - you should create your own thread when asking a completely separate question. Having said that, we don't do YOUR homework for you. When you are given homework, that is to show to your teacher that you have learn what you have been taught so far. If you can't do what you have been asked then tell your teacher that you can't do it. Or at least make an attempt at writing a program that attempts to do what you have been asked. If you just have no idea what you need to do then perhaps your studying the wrong subject.
@Kevngb - Write it out like you would do it on paper. put it in order or steps.
Code the steps.

This is what you need to start any C++ program.

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

int main()
{
// Your code goes here.

return 0;
}


Show us your code and describe the problem your having for help.

How can I write each program so that the user can continue the program with multiple data sets until he/she wishes to quit the program.
int numerator ,denominator; //variable declaration

cout << "Please enter the numerator: "; //prompt
//cout: standard output stream
// << : insert operator
cin >> numerator;
//cin: satndard input stream
cout << "Please enter the demoinator: ";
cin >> denominator;
cout << "The whole number is: " << numerator/denominator << endl;
cout << "The remainder is: " << numerator%denominator << endl;
You would put the core of your program inside a do{}while(condition to exit}; block. Then when the user enters the condtion to flag that they wish to exit the do while loop exits as the while condition is then true.
Last edited on
Nalaxer14, you've been asked already to start your own threads for your own problems, and not try and hijack other threads. If you continue to do this, you'll get reported to the admins here.
Topic archived. No new replies allowed.