Title: Arithmetic and I/O
Course: COP1000: Introduction to Programming > Section: Module Eight

Introduction

Depending on the language used there are any several possible math expressions used in programming. The most common are the addition (+), subtraction (-), multiply (*), and divide (/). There can be additional math expressions, one of the most popular is modulus (%).

Input to the program can be done through the keyboard. Input can be read directly from the command line or a Graphical User Interface (GUI) can be used. Most programmers start with keyboard input through the command line. Many programming languages ask that you include a Library to get input from the keyboard. Output to the screen is usually also defined in the same Library.

Another option for input and output is through files. Files are located on the computer in static form and your program can open that file and read from it. Files typically can be found in either text or binary formats. Text files are human readable while binary files are not. Most languages provide a Library for the input and output to files. Reading is typically done one line at a time.

Objectives

Upon completion of this module, the student will be able to:

Define the following: "Mathematical Expressions", "modulus", "keyboard input", "file input", "file output"
Gather user input from the keyboard and output to the screen
Gather data from a file and output to a file
Conclude mathematical calculations in a program

Readings & Resources

Chapter 2: The Interactive Shell p. 8-11
Chapter 5: Jokes p. 50
Chapter 8: Flow Charts p. 91