Weird midterm results
I've graded many tests from 2025. Here are the most hilarious results from C programming midterms. (From the second midterm, which was a little more technical in terms of the C language)
2025. second midterm
Everything MUST return false:
bool inside(Set* h, int found) {
/* ... */
while(/* ... */) {
if(mover->szam == found) return false;
}
/* ... */
return false;
}
No return?:
void inside(Set* h, int found) {
/* ... */
if(mover->szam == found) break;
/* ... */
}
The midterm was for the C language, this syntax is unacceptable there:
Set* h = Set{};
WTF syntax and initialization:
typedef struct {
int num = {2, 3, 9, 13, 20};
Halmaz* elso;
} Halmaz_elso;
Magic sizeof for linked lists:
Lista* betesz(Lista* halmaz, int uj) {
Lista* uj_elem = malloc(sizeof(halmaz) + sizeof(Lista*));
/* ... */
}
Yet another unreachable break statement:
...
if(l_list->next == NULL){
return l_list; break;
}
Yet another asolute cinema:
#include
typedef struct Set{
int data;
struct Set* next;
} Set;
Set* union(Set* s1, Set* s2){
int list1[50];
int counter = 0;
while(s1->next != NULL){
while(s1->next != NULL){ //O(n^2)????? Block nested loop join
if(s1->data == s2->data){ //THIS WILL NEVER go through s2 whole.
list1[counter] = s1->data; //What is length(s1)>50 ???
counter++;
}
}
}
list1[counter] = NULL; //WTF? int array!
//The below text was LITERALLY on the midterm sheet!!
Set* n->data = list1[0];
// -||-
// -||-
// -||-
// -||-
return n; //WTF?? Did he mean to generalize the assignment (which was bad anyway)??
}
Instant memory leak:
...
Set* n = malloc(...);
n = NULL; //^------ (ᕗ ͠° ਊ ͠° )ᕗ
//Proceeds to use n with leak + seg fault, refuses to elaborate, leaves.
...
Tuples in C????:
...
Set* n = {...}; //This was there literally.
...
New syntax in C????:
typedef enum Halmaz(){
int ertek;
int* halmaz;
}