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:bcf0

This is an old revision of the document!


Corning Community College

ENGR1050 C for Engineers

Project: LOGIC - BINARY COUNTER FUN (bcf0)

Objective

To create a program that can perform the task of a binary counter, in incrementing or decrementing fashion.

Reading

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

Program

It is your task to write a program that, upon accepting various pieces of input from the user, acts as a binary counter, displaying the resultant values in binary as from a starting to and ending progression.

Specifications

Your program should:

  • have valid, descriptive variable names of length no shorter than 4 symbols
  • have consistent, well-defined indentation (no less than 4 spaces per level of indentation)
    • all code within the same scope aligned to its indentation level
  • have proximal comments explaining your rationale and what is going on, throughout your code
  • to STDERR, prompt for the starting value (0-1023)
    • properly store this in a variable of type signed short int
  • to STDERR, prompt for the ending value (0-1023)
    • properly store this in a variable of type signed short int
  • immediately after each input, check to make sure starting and ending values fall appropriately in the range stated; if in violation, display an error (to STDERR) and exit with a non-zero value.
  • check the starting and ending values to determine if we are to perform an incrementation or a decrementation.
  • in binary, display the starting number and all the others as well to STDOUT
  • proceed to the next value in sequence, doing the same
  • keep going until you have arrived at the ending value, displaying it as well
  • using a single return statement at the conclusion of the code, return a 0 indicating successful operation

Some additional points of consideration:

  • Note that the driving variables in your loops need to be at least of type short int, otherwise you may get a warning when you compile it.

Execution

Sample incrementation run

lab46:~/src/c4eng/bcf0$ ./bcf0
Enter starting value (0-1023): 12
Enter ending value (0-1023): 28
0000001100
0000001101
0000001110
0000001111
0000010000
0000010001
0000010010
0000010011
0000010100
0000010101
0000010110
0000010111
0000011000
0000011001
0000011010
0000011011
0000011100
lab46:~/src/c4eng/bcf0$ 

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

Sample decrementation run

lab46:~/src/c4eng/bcf0$ ./bcf0
Enter starting value (0-1023): 17
Enter ending value (0-1023): 0
0000010001
0000010000
0000001111
0000001110
0000001101
0000001100
0000001011
0000001010
0000001001
0000001000
0000000111
0000000110
0000000101
0000000100
0000000011
0000000010
0000000001
0000000000
lab46:~/src/c4eng/bcf0$ 

Sample run with invalid input given (scenario 1)

lab46:~/src/c4eng/bcf0$ ./bcf0
Enter starting value (0-1023): 5543
ERROR: input value must be between 0-1023!
lab46:~/src/c4eng/bcf0$ 

Sample run with invalid input given (scenario 2)

lab46:~/src/c4eng/bcf0$ ./bcf0
Enter starting value (0-1023): 255
Enter ending value (0-1023): 7168
ERROR: input value must be between 0-1023!
lab46:~/src/c4eng/bcf0$ 

Reference

In the C4ENG public directory, inside the bcf0 subdirectory, will be a copy of my implementation (in executable form), which abides by the project specifications. Please compare its output against that of your implementation.

Submission

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

  • Code must compile cleanly (no warnings or errors)
  • Output must be correct, and match the form given in the sample output above.
  • Code must be nicely and consistently indented
  • Code must be well commented
  • Do NOT double space your code. Group like statements together.
  • 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 bcf0 bcf0.c
Submitting c4eng project "bcf0":
    -> bcf0.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:bcf0:final tally of results (78/78)
*:bcf0:proper error checking and status reporting performed [13/13]
*:bcf0:correct variable types and name lengths used [13/13]
*:bcf0:proper output formatting per specifications [13/13]
*:bcf0:runtime tests of submitted program succeed [13/13]
*:bcf0:no negative compiler messages for program [13/13]
*:bcf0:code is pushed to lab46 repository [13/13]

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 are subject to a 25% overall deduction
haas/fall2019/c4eng/projects/bcf0.1569847570.txt.gz · Last modified: 2019/09/30 12:46 by wedge