correctcppis_odd

January 31, 2018 ยท View on GitHub

BranchTravis CICodecov
masterBuild Statuscodecov.io

Correct C++ chapter 'is odd'.

Goals

  • Respond to exceptions

Prerequisites

Exercise

Write a command-line interface (CLI) program that determines if its argument is an odd number.

If there are more arguments supplied, ignore the ones beyond the first

Call to is_oddOutputExit status
./is_oddAny1
./is_odd 1true (with newline)0
./is_odd 2false (with newline)0
./is_odd nonsenseAny1
./is_odd 12345678901234567890Any1
./is_odd 2 1false (with newline)0

With 'Any' output, you can choose to:

  • inform the user, for example: 'Error: must supply one argument'
  • give no ouput at all: the exit status of 1 indicates that the program ended with an error

This is the code you start with:

main(argc, argv)
{
  //Your code here
}

References