Due date: tuesday 27/6.
Answer the exercises 1 to 15 of Chapter 2.
Start from the program given at https://goo.gl/9VuMdX
Write a functionmap
that takes as arguments:
int
int
int
and returns an int
The function does not return any value.When given an array a
and a function f
, map
replaces each element a[i]
of array a
by f(a[i])
.
Write two functions int plusOne(int)
and int square(int)
.
Add to the main
fuction the required code to apply funcions plusOne
and square
to the array by using the map
function.
(There is no need to add printf
statements since PythonTutor enables us to directly visualize the array).
Reimplement Program P3.1 in PythonTutor, doing the following changes:
scanf
to get random values between 0 and 9.printf
anythingmain
function?freeLL
that frees the memory occupied by the linked list; use it.