Created
April 29, 2012 19:11
-
-
Save kdmkdmkdm/2552781 to your computer and use it in GitHub Desktop.
(24): error C2065: 'i' : undeclared identifier
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
| // giAverage2.cpp : Defines the entry point for the console application. | |
| // | |
| #include "stdafx.h" | |
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| //declare | |
| int valuesToAverage = 0; | |
| float valueOfCurrentInput = 0.0f; | |
| float sum = 0.0f; | |
| float avg = 0.0f; | |
| cout << "Enter the number of values to average: "; | |
| cin >> valuesToAverage; | |
| //find sum | |
| for(int i = 0; i <= (valuesToAverage - 1); ++i) | |
| { | |
| cout << "[" << i << "] = "; | |
| cin >> valueOfCurrentInput; | |
| sum += valueOfCurrentInput; | |
| //calculate average | |
| avg = sum / valuesToAverage; | |
| } | |
| // Show Average. | |
| cout << "Average = " << avg << endl; | |
| } |
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
| // giAverage2.cpp : Defines the entry point for the console application. | |
| // | |
| #include "stdafx.h" | |
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| //declare | |
| int valuesToAverage = 0; | |
| float valueOfCurrentInput = 0.0f; | |
| float sum = 0.0f; | |
| float avg = 0.0f; | |
| cout << "Enter the number of values to average: "; | |
| cin >> valuesToAverage; | |
| //find sum | |
| for(int i = 0; i <= (valuesToAverage - 1); ++i); | |
| { | |
| cout << "[" << i << "] = "; | |
| cin >> valueOfCurrentInput; | |
| sum += valueOfCurrentInput; | |
| //calculate average | |
| avg = sum / valuesToAverage; | |
| } | |
| // Show Average. | |
| cout << "Average = " << avg << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment