Exercise 10
Added Exercise 10 to Repo
This commit is contained in:
45
Informatik_I/Exercise_10/Task_1b/README.org
Normal file
45
Informatik_I/Exercise_10/Task_1b/README.org
Normal file
@@ -0,0 +1,45 @@
|
||||
#+title: Task 1b: Understanding Pointers - Add
|
||||
|
||||
#+author: JirR02
|
||||
* Task Description
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: task-description
|
||||
:END:
|
||||
Complete the definition of function add by editing the file =add.cpp=
|
||||
according to its specified pre- and post conditions.
|
||||
|
||||
We provide a test program using the implemented function to add two
|
||||
values given by the user.
|
||||
|
||||
** Input
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: input
|
||||
:END:
|
||||
Integers a, b.
|
||||
|
||||
For example
|
||||
|
||||
#+begin_src shell
|
||||
21 35
|
||||
#+end_src
|
||||
|
||||
** Output
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: output
|
||||
:END:
|
||||
The test program prints the sum of a and b.
|
||||
|
||||
For example, for the input given above this value is 56.
|
||||
|
||||
* Solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: solution
|
||||
:END:
|
||||
#+begin_src cpp
|
||||
#include "add.h"
|
||||
|
||||
// PRE: a, b, and res are valid pointers to integer values.
|
||||
// POST: integer at location res contains the result of adding the integer at
|
||||
// location a and the integer at location b.
|
||||
void add(int *res, const int *a, const int *b) { *res = *a + *b; }
|
||||
#+end_src
|
Reference in New Issue
Block a user