rendered paste body//============================================================================
// Name : inout.cpp
// Author : Mads Munch Hansen
// Version :
// Copyright : Copyright (c) 2007
// Description : My dablings
//============================================================================
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
float getAvg (vector< float > number, int n){
float sum;
float answer;
for (int i=0; i < n; i++){
sum += number[i];
}
answer = (sum)/n;
return(answer);
}
int main() {
int n;
string input;
float buffer;
vector< float > numbers;
cout << "Type in your numbers, end with 'end' ";
for (n=0; input != "end"; n++){
getline(cin,input);
stringstream(input) >> buffer;
numbers.push_back(buffer);
}
cout << "Average is: "<< getAvg(numbers,n);
return 0;
}