Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Input / Output Questions
C file I/O with fseek and fgets: if source.txt contains the single line "Be my friend", what does this program print? #include
int main() { FILE *fs; char c[10]; fs = fopen("source.txt", "r"); c[0] = getc(fs); // read 'B' fseek(fs, 0, SEEK_END); // go to end of file fseek(fs, -3L, SEEK_CUR); // back up 3 bytes fgets(c, 5, fs); // read up to 4 chars into c puts(c); return 0; }
Self-referential format (a classic quine-style string): what exact output does this program produce? #include
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; int main() { printf(str, 34, str, 34); return 0; }
Understanding printf escapes: how many % signs are printed here? #include
int main() { printf("%%%% "); return 0; }
1
2