Created
September 20, 2013 03:34
-
-
Save kdmkdmkdm/6632984 to your computer and use it in GitHub Desktop.
average
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Qaverage.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int numToAverage = 0; | |
float sum = 0.0f; | |
float avg = 0.0f; | |
cout << "Enter the number of values to average: "; | |
cin >> numToAverage; | |
float average[numToAverage]; | |
for (int i = 0; i > (numToAverage - 1); ++i) | |
{ | |
cout << "[" << i << "] = "; | |
cin >> average[i]; | |
sum += average[i]; | |
} | |
avg = sum / numToAverage; | |
cout << "Average = " << avg << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment