Question
In C++, use SML programs to accomplish each of the following tasks: a) Use a sentinel-controlled loop to read positive numbers and compute and display
In C++, use SML programs to accomplish each of the following tasks:
a) Use a sentinel-controlled loop to read positive numbers and compute and display their sum. Terminate input when a negative number is entered.
b) Use a counter-controlled loop to read seven numbers, some positive and some negative, and compute and display their average.
c) Read a series of numbers, and determine and display the largest number. The first number read indicates how many numbers should be processed.
For input you should read the instructions from a file (after prompting the user for the name of the file to read). Make the intro banner say "Welcome to Simpletron! Enter the name of the file containing your program:"
Here is a sample of the output expected:
Execution halted normally
REGISTERS:
accumulator -1
instructionCounter 6
instructionRegister 4300
opcode 43
operand 0
MEMORY:
0 1 2 3 4 5 6 7 8 9
0 1007 1008 2007 3008 2109 1109 4300 4 -5 -1
10 0 0 0 0 0 0 0 0 0 0
. . .
90 0 0 0 0 0 0 0 0 0 0
Please show the output files for a, b, and c. Thank you.
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