Question: C++ #include #include using namespace std; int counter; int sum = 0; int number; ifstream inNums; void SumNumbers(ifstream& inFile, int& answer); // Sums the numbers
#include
#include
using namespace std;
int counter;
int sum = 0;
int number;
ifstream inNums;
void SumNumbers(ifstream& inFile, int& answer);
// Sums the numbers on inFile.
int main ()
{
inNums.open("numeric.dat");
{
int sum = 0;
SumNumbers(inNums, sum);
cout
cout
}
SumNumbers(inNums, sum);
cout
cout
return 0;
}
//****************************************************
void SumNumbers(ifstream& inFile, int& answer)
{
static int counter = 1;
while (counter
{
inFile >> number;
answer = answer + number;
counter++;
}
}
Exereise 1: Run program Scope to check your answers. Were your answers cornect? If not explain what you did wrong. Exercise 2: counter, aun number, ns, and Sunluabers Exercise 3 int main return-0 void.Sunlunbera(ifstreami-inFile inti-aawer 210 Chapeer Exercise 4: Block 1 has no local identifiers Block 2 has local identifier sun which hides global identifier eu Block 3 has ee local identifiers: inFile, annet, and couhteE Exercise 5: Aotamatie local variable: sun local to automatic variables. All of the parameters are also Exercise 6: Static local variable: counter Gocal to 31. All loball variables are static Exereise 1: Run program Scope to check your answers. Were your answers cornect? If not explain what you did wrong. Exercise 2: counter, aun number, ns, and Sunluabers Exercise 3 int main return-0 void.Sunlunbera(ifstreami-inFile inti-aawer 210 Chapeer Exercise 4: Block 1 has no local identifiers Block 2 has local identifier sun which hides global identifier eu Block 3 has ee local identifiers: inFile, annet, and couhteE Exercise 5: Aotamatie local variable: sun local to automatic variables. All of the parameters are also Exercise 6: Static local variable: counter Gocal to 31. All loball variables are static
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
