Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ #include #include using namespace std; int counter; int sum = 0; int number; ifstream inNums; void SumNumbers(ifstream& inFile, int& answer); // Sums the numbers
C++
Exercise 1: File numeric.dat contains the following values: 10 20 30 40 10 20 30 40. What is printed? Exercise 2: List the global identifiers Exercise 3: Circle each of the blocks in program Scope and number them from top to bottom Exercise 4: List the local identifiers and state the block(s) in which each is accessible Exercise 5: List the automatic local variables Exercise 6: List the static local variables #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++;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started