Hi, I'm pretty new here. I've started programming C++ on and off now for a while now, but never got anywhere with it. So I decided to stick with my book examples and see where it takes me.
Okay my goal is to write a program that prompts the user for 7 values, stores them in an array, and then prints each of them out, and their sum.
It also notes that I need two for loops to be included; one for collecting the inputs, and one for calculating the sum and printing the value.
This is what I have so far
I tried initializing the array values with user inputted values on the same line of code, but it gave me a funky error.
Okay, so far the program takes everything in, and after entering the 7th number, it spits out Random letters, numbers... I've seen this happen when trying to do math with Letters, but I don't see how it's adding letters...they should have value.
Can I get a few tips ? Also, any tips for those for loops It says to write ?
I appreciate your time
Okay my goal is to write a program that prompts the user for 7 values, stores them in an array, and then prints each of them out, and their sum.
It also notes that I need two for loops to be included; one for collecting the inputs, and one for calculating the sum and printing the value.
This is what I have so far
Code:
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int i,;
double n, m, o, p, q, r, s, t;
double scores[7];
scores[0] = n;
scores[1] = m;
scores[2] = o;
scores[3] = p;
scores[4] = q;
scores[5] = r;
scores[6] = s;
cout << "Enter seven numbers for me to store. I will then\n print each out, and their total\n";
cin >> n >> m >> o >> p >> q >> r >> s;
for(i = 0; i < 7; i++){
cout << scores[i] <<", ";
}
cout << "\n The total sum =" << n + m + o + p + q + r + s;
system("PAUSE");
return 0;
}
Okay, so far the program takes everything in, and after entering the 7th number, it spits out Random letters, numbers... I've seen this happen when trying to do math with Letters, but I don't see how it's adding letters...they should have value.
Can I get a few tips ? Also, any tips for those for loops It says to write ?
I appreciate your time
Comment