User Tools

Site Tools


Sidebar

projects

pct0 (bonus; due 20190821)
cci0 (due 20190821)
wcp1 (due 20190821)
dtr0 (bonus; due 20190828)
pct1 (due 20190828)
wcp2 (due 20190828)
pct2 (due 20190904)
wcp3 (due 20190904)
sof0 (due 20190911)
pct3 (due 20190911)
wcp4 (due 20190911)
dow0 (due 20190918)
pct4 (due 20190918)
wcp5 (due 20190918)
mtf0 (due 20190925)
pct5 (due 20190925)
wcp6 (due 20190925)
mtf1 (due 20191002)
pct6 (due 20191002)
wcp7 (due 20191002)
bcf0 (due 20191010)
epf1 (due 20191010)
pct7 (due 20191009)
wcp8 (due 20191009)
cnv0 (due 20191023)
pct8 (bonus; due 20191023)
pct9 (due 20191023)
wcp9 (due 20191023)
cnv1 (due 20191030)
pctA (due 20191030)
wcpA (due 20191030)
fwf0 (due 20191106)
pctB (due 20191106)
wcpB (due 20191106)
cos0 (due 20191113)
pctC (due 20191113)
wcpC (due 20191113)
eoce (due 20191211 by 172959)
haas:fall2019:c4eng:projects:mtf0

This is an old revision of the document!


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:

  • for loop - typically used when we have a known starting and stopping place, and a clear means of progressing from start to end (top-driven, runs 0 or more times)
  • while loop - used when we know when we'd like to stop, but do not necessarily know where we will start. Much more conditional in application (top-driven, runs 0 or more times)
  • do-while loop - like the while, only we perform the test at the very bottom (bottom-driven, runs 1 or more times)

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:

  • prompt the user for the operation ('+' for addition, '*' for multiplication)
  • perform the task (process)
  • display the final value (output)

Execution

lab46:~/src/c4eng/dow0$ ./dow0
Which year: 2014
January 1st, 2014 falls on: Wednesday
lab46:~/src/c4eng/dow0$ 

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

Output Specifications

Your program must output as follows:

  • Input prompts, and everything else except the actual day of the week should be output to STDERR
  • The calculated day of the week needs to be displayed to STDOUT
  • The output MUST contain the “January 1st, YEAR” string
    • YEAR must be all 4 digits, exactly as input by the user
  • The calculated day of the week must be fully spelled out and correct, with the first letter capitalized, remaining letters lowercase.

Reflection

Be sure to provide any commentary on your journal regarding realizations had and discoveries made during your pursuit of this project.

  • Try this algorithm on some years in the 20th century and see how it fares.
    • Is it correct? Is it correct for any of them?
    • If it isn't correct, is it consistently off by a value?

This isn't just about implementing a particular algorithm, it is about understanding an algorithm- its domain of correctness, and its limitations.

Submission

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

  • Code must compile cleanly (no warnings or errors)
  • Executed program must display a total of 2 lines, one for input, one for output.
  • Output must be correct, and match the form given in the sample output above.
  • Code must be nicely and consistently indented (you may use the indent tool)
  • Code must be commented
  • Output Formatting (including spacing) of program must conform to the provided output (see above).
  • Track/version the source code in a repository
  • Submit a copy of your source code to me using the submit tool.

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:data stored and calculated pursuant to algorithm and specifications [4/4]
*:mtf0:code is pushed to lab46 repository [4/4]
*:mtf0:adequate indentation and comments in dow0.c [4/4]
*:mtf0:program uses indicated algorithm [12/12]
*:mtf0:output conforms to project specifications [12/12]
*:mtf0:runtime tests of dow0.c succeed [12/12]
*:mtf0:no negative compiler messages for dow0.c [4/4]

Additionally:

  • Solutions not abiding by spirit of project will be subject to a 25% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2019/c4eng/projects/mtf0.1568639386.txt.gz · Last modified: 2019/09/16 13:09 by wedge