For/Next Loops...adding 10 numbers...
I have an assignment in programming class, that degrades what I know and can do. I have to make a program using For/Next loops and it has to ask for a name, display the name, then ask for 10 numbers, add them, and get the average, displaying both sum and average. My program works...but it doesnt add the numbers. Dont worry about the average part, not there yet. For/Next loops are killing me....way behind my times. :P Here is my code:
Code:
#include<iostream>
#include<string>
using namespace std;
int main(){
string name;
double num[10],sum;
int i;
cout<<"Please enter your name: "<<endl;
cin>>name;
cout<<"Your name is "<<name<<endl;
for(i=0,i<10;i++;){
cout<<"Please enter a number: ";
cin>>num[i];
sum=i+num[10];
cout<<"The sum of your numbers equals "<<sum<<endl;
}
return(0);
}
I know my problem lies in the for statement...but i just cant seem to understand it. Thank you.