Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ // Program Loops demonstrates various looping structures. #include #include using namespace std; int main () { ifstream inData; int value; inData.open(Loop.dat); { // while
C++
// Program Loops demonstrates various looping structures.
#include
#include
using namespace std;
int main ()
{
ifstream inData;
int value;
inData.open("Loop.dat");
{ // while loop
int counter = 1;
int sum = 0;
while (counter
{
inData >> value;
sum = sum + value;
counter++;
}
cout
}
{ // do-while loop
int counter = 1;
int sum = 0;
do
{
inData >> value;
sum = sum + value;
counter++;
} while (counter
cout
}
{ // for loop
int sum = 0;
for (int counter = 1; counter
{
inData >> value;
sum = sum + value;
}
cout
}
return 0;
}
Check
10
20
30
40
10
20
30
40
10
20
30
40
----------------------------------------------------------------------------------------------------------
// Program Switches demonstrates the use of the Switch
// statement.
#include
using namespace std;
int main ()
{
char letter;
int first;
int second;
int answer;
cout Exercise 1: If file loop. dat contains the following values, what is printed? 10 20 30 40 10 20 30 40 10 20 30 40 Exercise 2: Which of these loops are pretest loops? Which are posttest loops? Examine program Switches and answer Exercises 3 and 4
cin >> letter;
while (letter != 'Q')
Check
There are lots of symbols in this file: ..;;??
.,.,.,?:::
___________________________________________________________________
// Program CountMarks counts punctuation marks in a file.
#include
#include
using namespace std;
int main ()
{
ifstream inData;
char symbol;
int periodCt = 0;
int commaCt = 0;
int questionCt = 0;
int colonCt = 0;
int semicolonCt = 0;
inData.open("switch.dat");
/* FILL IN */
return 0;
}
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