0% found this document useful (0 votes)
15 views

Week 4 Lab

This document provides instructions for a CS211 lab on input/output using the Wombat 1 machine. Students will learn to read inputs from files and write outputs to files. They will complete exercises to read and add numbers from a file and print the sum, compute a function from values in a file, and find the largest input from a user until a sentinel value is entered.

Uploaded by

Titan Thanos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Week 4 Lab

This document provides instructions for a CS211 lab on input/output using the Wombat 1 machine. Students will learn to read inputs from files and write outputs to files. They will complete exercises to read and add numbers from a file and print the sum, compute a function from values in a file, and find the largest input from a user until a sentinel value is entered.

Uploaded by

Titan Thanos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS211 Lab 3

Objectives

After completing this lab, students should be able to

 read inputs from a file and write outputs to a file


 write programs to solve simple problems using Wombat 1 machine

Wombat File Input/Output

Instead of accepting user input from the console (keyboard), the Wombat machine is able to
read inputs from and write outputs to a text file. This can be enabled by setting the following
options in the simulator:

Click: Execute -> Options -> IO connections

Then choose File… for input and/or output from the drop-down list. The default is [Console].
You will need to identify the files from the Open Dialog box that appears next.

Question 1

Using the given input.txt file and a blank output.txt file, change the above settings in your
machine and run the sample program from Lab 1 (sample.txt) that reads and adds a set of
numbers from the input file and prints the sum to the output file.

Question 2

Write a machine language program which reads three integers from a text file and computes
the result for the following function:
Z=A+BxC
where A, B and C are the three integers read from the file (assume first value is A, second value
is B, and third value is C). After computation, display the result of the function (value Z) on the
IO Console.

Question 3

Write a machine language program that accepts integer inputs from the user (console input),
determines the largest value of the inputs entered and prints this largest value on the console.
The program should keep prompting for user input (accept both positive and negative integers)
until user enters -99 (this is the sentinel value, thus should not be used in computation).

You might also like