Table of Contents

Corning Community College

ENGR1050 C for Engineers

Project: LOOPS - MATH TABLE FUN (mtf0)

Objective

To start incorporating loops into our problem-solving repertoire, aiding us in displaying information related to various math tables.

Reading

In “The C Book”, please read through Chapter 4.

Background

Although we have encountered the use of loops in various class examples programs driving electronics on the raspberry pi, being able to utilize a loop to alter control flow in your programs is a very important skill. It starts to usher in dramatically increased levels of optimization in our solutions, saving us from needlessly writing redundant code that is largely the same, but only changes in some predictable way.

Types of Loops in C

There are 3 types of loops available to us in C, all numerical/conditional in nature:

Program

It is your task to write the program that will use loops and other programming concepts learned this far to automate the display rows of various mathematical tables (addition or multiplication, as indicated by the user). This information is potentially of value to some of your letter division efforts in the pctX projects.

Your program should:

Execution

Sample run using multiplication

lab46:~/src/c4eng/mtf0$ ./mtf0
Which operation ('+' or '*'): *
Row (0-9): 4
Starting Column (0-9): 1
Ending Column (0-9): 5
 4:  4  8 12 16 20
lab46:~/src/c4eng/mtf0$ 

The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate.

Sample run using addition

lab46:~/src/c4eng/mtf0$ ./mtf0
Which operation ('+' or '*'): +
Row (0-9): 5
Starting Column (0-9): 2
Ending Column (0-9): 7
 5:  7  8  9 10 11 12
lab46:~/src/c4eng/mtf0$ 

Sample run with invalid operation given

lab46:~/src/c4eng/mtf0$ ./mtf0
Which operation ('+' or '*'): x
ERROR: Must specify either '+' or '*'.
lab46:~/src/c4eng/mtf0$ 

Sample run with invalid column configuration

lab46:~/src/c4eng/mtf0$ ./mtf0
Which operation ('+' or '*'): +
Row (0-9): 5
Starting Column (0-9): 7
Ending Column (0-9): 2
ERROR: Starting column is greater than ending column
lab46:~/src/c4eng/mtf0$ 

Submission

To successfully complete this project, the following criteria must be met:

To submit this program to me using the submit tool, run the following command at your lab46 prompt:

$ submit c4eng mtf0 mtf0.c
Submitting c4eng project "mtf0":
    -> mtf0.c(OK)

SUCCESSFULLY SUBMITTED

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

What I'll be looking for:

78:mtf0:final tally of results (78/78)
*:mtf0:proper error checking and status reporting performed [13/13]
*:mtf0:correct variable types and name lengths used [13/13]
*:mtf0:proper output formatting per specifications [13/13]
*:mtf0:runtime tests of submitted program succeed [13/13]
*:mtf0:no negative compiler messages for program [13/13]
*:mtf0:code is pushed to lab46 repository [13/13]

Additionally: