Homework I

Homework 1: Tabulating a function y=f(x)

For homework I, you will have to create a software solution, that will solve a function y = f(x) within the limitations specified. The results must be displayed as a table with columns for X and Y values. Some hints about aligning it can be found from printf tips example.

The program will get the initial data from the keyboard (entered by the user) as real numbers!

Argument (xi) Function value yi=f(xi)
x1 y1
x2 y2
xn yn

From your personal variant you will find the formulas for both xand yi.

Function value should only be shown if the value exists. If the value cannot be calculated for the given x or is a complex number, You can choose to display “missing” or “complex”. If you wish, you are free to calculate the imaginary numbers and display them as well. Regardless of the variant, you will need to find up to 20 results.

The inputs for the program come from the keyboard and is entered by the user. All inputs besides the number of steps N must support real numbers. Number of steps N is an integer.

You will need to create and submit a program written in C, an algorithm for the program represented as an UML activity diagram and a report.

Homework variant

Report

You will have to write a detailed report on the solution you made. The report must be well structured and detailed. The quality of the report is a part of the grade.

The report must adhere to IT faculty’s thesis guidelines provided here https://haldus.taltech.ee/sites/default/files/2021-04/FIT_Author_Guidelines_ENG.pdf

To make this easier for you, we are providing a template that follows these guides and is adjusted to fit the homework requirements. Use it for your writing of the documentation!

Adjusted report template (MS Word)

Download the template: https://blue.pri.ee/ttu/files/iax0583/mallid/mall_en_pr1_kod1.dotx

Each section of the template contains comments written in blue text what should be included. Use these blue texts to guide you. Once the report is finished, delete the blue text before submitting.

Template contains styles that match the requirements for tables,  body text etc. You may need to manually select these styles to make sure your work corresponds to the requirements.

The structure in the template can be adjusted . It’s also recommended to add (sub)headings as you see fit to create a better structure.

Generic template (LaTeX)

The official university LaTeX templates are available on  https://www.overleaf.com/latex/templates/tagged/taltech. Since this is a generic template, please look through the adjusted dotx template to make sure that all required parts are covered.

Generic template (MS Word, OpenOffice)

If you wish to use a generic template and adjust it from scratch, you can find them here: http://www.tud.ttu.ee/im/Aila.Lainurm/ITT_Autorikomplekt/

NB! When using a generic template, please look through the adjusted dotx template to make sure that all required parts are covered.

Documentation contents

Your report should contain the following sections:

  • Title page
  • Declaration of originality
  • List of abbreviations and terms (can be omitted if not present)
  • Table of contents
  • List of figures and tables (can be omitted if not present)
  • Task description and your task variant
  • Function analysis
    • Analyze your function and it’s domain
    • Plot the function given to you
      Possible tools to create it [google], [wolfram alphat], Microsoft Excel, etc.
  • Description of the solution
    • A write up on the solution. Use the key points brought out in the template! The length of the written part must be at least 3 / 4 of a page, at maximum 2 pages. The description must be well structured, use tables, lists and other elements. It should not be a wall of text!
    • An algorithm of the program modelled as a UML activity diagram.
  • Summary
    • Write a few sentences about your approach to the task and progression during it.
    • Write a few sentences about the task itself and the complexity of it.
    • If possible, give an estimate on the workload.
    • Additional comments, emotions, thoughts
  • References (can be omitted if not present)
    • Everything that wasn’t covered within the subject and that you didn’t create on your own.
    • This includes help from a friend or a colleague: https://libraryguides.vu.edu.au/ieeereferencing/personalcommunication
    • If you used AI tools (i.e. ChatGPT), they must also be referenced
    • All references must be precise. References such as stackoverflow.com or google.com are meaningless. It must be directly to the page where you got the information from.
  • Screen capture(s) of the working program
    • Screen captures should illustrate various situations that you program can handle, as well as the normal behavior.
    • Screenshots can be added as an appendix or embedded within the write up of the solution – in this case you can extend the length by the amount of pictures.

Common issues with the report

This is a list of commonly made mistakes when writing the report

  • The title page is accurate.  You need to specify to where you are submitting this report, not where you are studying! At minimum, the name of the university and the institute of the person who this report is intended for.
  • Year is accurate on the title page
  • You used the styles in the report as well as the automatically generated table of contents, figures, tables and references. I.e.:
    • Normal text must use the style “body text”
    • First level heading must use the style “Heading 1”
  • There are no blank pages or headings.
  • All headings are followed by text. A heading that only contains an image or a table isn’t enough – it must be explained.
  • Tables and figures need to be referenced in the text. If necessary, additional comments can be added.
  • The description is formatted properly – good structure, use of subheadings, tables, lists etc. to improve on readability. It shouldn’t be a wall of text.
  • Algorithm must be readable. It’s recommended to export a vector graphic image and embed it in the document.
  • Your report can only include snippets of the code and only when it is necessary to illustrate a part of the description. Such code must be aligned to the left, indented and use a monospaced font.
  • The document includes screenshots of your program, running in various situations. Do not include a screenshot of your entire desktop or your code in a text editor.

Requirements for the standards and environment

The program must be written in the C programming language. You are permitted to use the C90 and C99 standards. Upon an agreement, you can also use newer standards such as C11 and C17.

In addition to using the standard C libraries, you are allowed to use C POSIX and GNU C libraries. Any libraries outside of this must be agreed upon separately.

Your program will be compiled and tested in a Linux environment, equivalent to the one in the lab computers (e.g. OpenSUSE SLED-15 SP5 or Ubuntu Linux 22.04 or later, using GCC-12 compiler). The software does not need to be compatible with other operating systems such as Windows or MacOS.

Code requirements

  • Code must adhere to the practices taught in the class so far.
  • Must not use GOTO statements.
  • Must not use global variables.
  • Must not use variable length arrays (VLA)
  • Must not have any unused components in the code (e.g. libraries, variables).
  • All of the x and y values must be stored inside an array or arrays of the suitable type. The output must use those arrays.
  • At maximum, must show 20 results.
  • All inputs (except for the step count) must support floating point values.
  • Code must adhere to the coding style, including (but not limited to):
    • Every file includes the authors name, dates and a short description of the file.
    • The code is commented.
    • Variable name must be self-explanatory and written in the correct style.
    • The code is indented, lines are within the maximum allowed length and spaces are put where required.
    • No magical numbers are found within the code
Algorithm requirements

Generic requirements:

  • Algorithm conforms to the UML activity diagram requirements
  • Algorithm is divided into swim lanes based on logical blocks.
  • Algorithm shows the indexing of the arrays.

Some checks to avoid common issues:

  • Every decision node has a condition specified.
  • All of the possible exits from a decision node are marked (e.g. in what condition will the program follow each path – true/false, const values for switch cases etc).
  • Every path from a decision node is viable – the conditions must be real, so that the flow can actually enter them.
  • If multiple paths merge (following a decision node), a merge node must be used.
  • No dead ends – You have to have a way to the exit from all of the nodes, actions etc.
  • No infinite loops – It must always be possible to exit them.

User defined functions

Homework 1 can be written as a monolithic main function. You are not required to create any functions, however it is also not forbidden. If you intend to create your own functions, following requirements must be met

  • Global variables are forbidden. Data must be passed using parameters and can be returned using return values.
  • Function prototypes are before the main function. Function body (declarative part) is after the main function.
  • Functions are commented as specified by the coding style.

Extra task for bonus points

It’s possible to receive up to 2 bonus points for the task.

To get the bonus points, the following requirements must be met in addition to completing all the basic requirements.

  • Program must be divided into reasonably sized functions
    • Functions must be documented as specified by the user defined functions section of this document.
    • Calculation and output of the results must be handled by different functions.
    • You must have at least one function returning a value
  • In addition to allowing the user input for the initial values, your program must have preconfigured (hardcoded into the source code) values for initial values which the user must be able to execute.
    • User must be able to choose if they want to enter the values or a preconfigured set of values is executed
    • You must have at least 2 sets of preconfigured values that demonstrate your program in different situations
  • Program must be able to calculate multiple sets of results without exiting. User must have an option to close the program when desired.
  • You must add a level 1 heading to the documentation called “Extra task”.
    • Describe the added features
    • Describe your thought process on how you chose the functions
    • Describe the chosen input sets and why they were chosen

Deadlines

A complete homework must be submitted no later than 27.10.2024 23:59:59 (local time)

Every week passed the deadline removes 1p from the maximum possible score. The late cost is capped at 5p, meaning if you submit 7 weeks late, you can still get up to 10p.

If we have questions about the submitted homework or are not sure about the original author of this work, we will grade this with 0p. In this case, the work must be defended.

If it becomes necessary, we will enforce the rules and guidelines of [Procedure for processing a student’s violation of academic practices and contemptible behavior in the School of Information Technologies]

We will only accept Your homework until the lockdown date (check introduction slides). Past that, submitting your homework will not be possible.

Submitting Your work

You need to submit the documentation in Adobe PDF format and all the necessary code files to compile your program.

Naming schema: HW1_<studentcode>_<firstname>_<lastname>

Example:

HW1_123456MVEB_Heli_Kopter.c
HW1_123456MVEB_Heli_Kopter.pdf

Submitting is done using Moodle:

https://moodle.taltech.ee/mod/assign/view.php?id=303391

Result and feedback

After your work has been checked and graded, you will see the result and feedback on Moodle (visible from your gradebook only!). If everything was well done, feedback may be absent.

Fixing your homework

You are allowed to fix and improve your homework score until the date of homework lockdown. All fixed submissions are subject to defense.

To fix your homework, first go through your feedback. Then contact your teacher and agree upon the process of how this homework can be fixed.

NB! If fixing the homework changes more than half of the original homework, it is considered as submitting a completely new homework, from which minus points can be deducted from depending on the time of submission.