Programming in C ++
Lab 1: Introduction to Language and Tools - Homework
General conditions
Important! Read the conditions for completing the assignments on the module's website! Tasks are submitted via the form on the module's website. Solutions will not be accepted via email. If you have any questions, please contact the internship supervisor. There are 14 days to solve the task.
Deadline 19.02.2023 23:59:59
Task 1 - More Features (4 points)
- Add the following features (as functions) to your project:
maximum
- finds the larger of the two integersproduct
- multiplies two integers and returns the product as an integerpower
- raises the first integer to the power of the second integer (if the result is a fraction or infinity, for example, for some negative power, output zero)gcd
- finds the greatest common divisor of the two integers (check that no input crashes)
- Complete the main program. The command line accepts two integers, and a function name can be specified. An error message must be issued for an incorrect number of parameters. The standard output must first output the two numbers from the command line, separated by a space, and then the result of a given function (separated by a newline). If the function was not specified, the results of all methods must be output (separated by a newline):
- smaller of two numbers
- greater of two numbers
- product of two numbers
- first number to the power of second number (see above)
- the largest common denominator of the two numbers
Sample output if the command line is program 42 2 minimum
42 2 2
Sample output if the command line is program 42 2
42 2 2 42 84 1764 2
Attention! The application should be able to perform tasks even with the wrong format input.
For example, zero can be used as the default input value.
Add the appropriate tests to the main test program.
Task 2 - Documentation (3 points)
Add Doxygen comments for all functions. Functions, parameters and return values must be specified in the documentation. The Doxygen file, which is used to generate the documentation, must also be submitted. In order to create the Doxygen file the program doxywizard can be used (included in Doxygen). You should note that (at least in Windows) the wizard writes absolute path into the generated Doxyfile (C:\Username\Folder\..), while we require a relative path.
HTML documentation is sufficient. LaTeX is not required.
NB! The standard name for the Doxygen configuration file is Doxyfile. With a different name, nothing simply happens because @doxygen
@ cannot find the doxy.conf file.
Task 3 - Makefile additions (3 points)
Add 3 more targets to Makefile
doc
- executes Doxygen, which generates documentation to folder docs
.
clean
- deletes object code, program files and documentation and nothing else.
all
- builds a program and creates documentation. If the rules for doc
or build
are changed then make all
must also work in the same way (don’t copy, refer). If make
is called on the command line, then
only the program should be built (no documentation).
For help: http://www.cprogramming.com/tutorial/makefiles.html
Additional task - Input from a file (1 extra point)
Modify the program for the first task so that if only one parameter is specified on the command line, it is processed as a file name and the file is opened for reading. The first line of the file contains two numbers that must be used to perform the same operations as in the first task. If there is no file with this name, a message must be issued in the standard error stream and the program must be stopped. If the file does not contain the expected content, the program must be able to handle it.
Let the file yksjakaks.txt
in the folder contain
1 2
Sample output of the command line program yksjakaks.txt
:
1 2 1 2 2 1 1