We aim to provide you with our previous exams from recent months. This will assist you in preparation and offer a clearer understanding of the structure, content, and types of questions.
This is the original exam from 17.01.2024
<aside> ⚠️ This exam consists of three parts: i) three code analysis questions (without an online IDE), ii) one debugging question (with an online IDE), and iii) a coding example (again, with an online IDE).
You are writing this exam in Exam TeachCenter and Safe Exam Browser, which means you have to stay within this exam environment. All the code provided is in the C programming language. Be as precise as possible with your answers. Questions 1 - 3 have to be answered completely correctly (which means you have to write the exact output), since they are evaluated automatically. You can assume that all provided code examples can be compiled correctly and they won’t produce a runtime error. To make the code snippets easier, we might not put it in a main function or include headers. You can assume that the code is working. For questions 4 and 5 you can use OnlineGDB. Please do not forget to copy the code from OnlineGDB into the input field. OnlineGDB does not store your answers. If the code is not in Exam TeachCenter by the end of the exam (which will be submitted automatically after the time is over), you will get 0 points on this question.
Important: After submitting the code analysis questions (part i) you cannot navigate back to these questions again.
All the best for the exam!
</aside>
What is the Output of this code snippet?
char* createArray()
{
char* arr = malloc(10 * sizeof(char));
strcpy(arr, "Hi ESP");
return arr - 1;
}
int main()
{
char* array = createArray();
printf("%c", *(array++ + 1));
printf("%s", (array + 3));
}
What is the Output of this code snippet?
void f(int arr[], int n)
{
for(int i = 0; i < n; i++)
{
arr[i] *= 2;
}
}
void p(int arr[], int n)
{
for(int i = 0; i < n; i++)
{
printf("%d ", arr[i]);
}
}
int main()
{
int number[] = { 1, 3, 5, 7, 9 };
f(number, sizeof(number) / sizeof(int));
p(number, sizeof(number) / sizeof(int));
}
What is the Output of this code snippet?
int main()
{
char s[] = "Inffeldgasse";
char* p = &s[3];
*p = '\\0';
printf("%s", s);
return 0;
}
<aside> ⚠️ Note: For this task, you may use an online IDE that you can access using the following link:https://www.onlinegdb.com/
</aside>