- Joined
- Apr 21, 2005
- Sythe Gold
- 5,470
- Messages
- 8,074
- Discord Unique ID
- 742989175824842802
- Discord Username
- Sythe
Some of you may know I've been a C programming tutor for a few years.
If you're taking a C programming course at university these are some of the harder types of questions you might find on a final exam:
Q1: Is the following valid C?
If you're taking a C programming course at university these are some of the harder types of questions you might find on a final exam:
Q1: Is the following valid C?
Q2: How many times does the following code print "hello\n"?#include<stdio.h>
int main() {int (*main)(); {}printf("hello world\n");}
return 0;
Q3: What does the following code do?#include <stdio.h>
#define _(x) (;; )
int main() {for _(int i = 0; i < 100; i++) {printf("hello\n");}
return 0;}
Q4: Why is the following a bad idea?int main(void);int(*__)()=main;int(**_)()=&__;int main(void){(*_)();}
Q5: What would the following code do?while(1) fork();
Q6: What is the following code equivalent to?if (*'z' = 010); {printf("%d", *'z');}
Q7: What is the type of foo in the following? Is it valid C?char a[10];
int b = 5;
*(a + b) = 5;
Q8: what is the return value of this function?typedef void *(*a)(void);
a (*(*foo)(void))(void);
Q9: What is the value of c after the following code is executed (assuming c is 2 before execution)?:int function(void) {return ({024;007;006;004;001;011});}
c += c++++c;


































