Professional Documents
Culture Documents
PG1 WS23 Exercise9
PG1 WS23 Exercise9
PG1 WS23 Exercise9
E 9.1) 50 points
Write a program that calls the functions sumIter() and sumRec() once each. These
functions should output the sum of numbers in a fixed interval [n, m].
E 9.2) 50 points
Write a program that outputs the uppercase alphabet in such a way that the first
and last letters are separated by a tab, followed by the second and second-to-
last letter, and so on:
A Z
B Y
…
M N
Solve the task using a recursive function. Note that the sequence stops when
reaching the pair "M N".
--------------------------------------------------------------------------------
#include <stdio.h>
int main()
{
int nStart = 0, nEnd = 0;
printf("Start value (integer): ");
scanf("%d", &nStart);
printf("End value (> Start value): ");
scanf("%d", &nEnd);
upAndDown(nStart, nEnd);
return 0;
}
/*
Calculation of the first x Fibonacci numbers
1. using non-recursive function
2. using recursive function
*/
#include <stdio.h>
int fibNonRec(int);
int fibRec(int);
int main() {
int nNum = 0, i = 0;
puts("");
return 0;
}
Write the missing function and recursion definition. Note that each function
call should calculate only a single Fibonacci number at the specified position
passed as a parameter. For the recursion, first, consider the mathematical
formula.
https://en.wikipedia.org/wiki/Fibonacci_sequence