Skip to content

janderkkotlarski/correct_cpp_is_odd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

correct_cpp_is_odd

Branch Travis CI Codecov
master Build Status codecov.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_odd Output Exit status
./is_odd Any 1
./is_odd 1 true (with newline) 0
./is_odd 2 false (with newline) 0
./is_odd nonsense Any 1
./is_odd 12345678901234567890 Any 1
./is_odd 2 1 false (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
}

External links

References

Packages

No packages published

Languages

  • QMake 98.3%
  • C++ 1.7%