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 scanf formatting: Given float a; and double b;, which scanf statement uses the correct conversion specifiers to read both values from input?
Safe line input in C: Between fgets() and gets(), which function is considered safe for reading a line of text (and why)?
C printf formatting: With float a = 3.14; and double b = 3.14;, which printf statement uses correct specifiers to print both values?
Behavior of fgets with Windows newlines: If a file contains the line "I am a boy\r ", what exact byte sequence will the char array str contain after calling fgets(str, size, fp)?
C file I/O API correctness: In the given program with three opened files, what happens when calling fclose(fp, fs, ft);?
Meaning of mode string in fopen: In the call fp = fopen("source.txt", "rb"); what does the mode "rb" instruct the C library to do?
Understanding fileno: In the program that opens "DUMMY.C" for writing and assigns t = fileno(fp);, what does t represent?
What does the FILE* returned by fopen actually point to in C? Consider FILE fp; fp = fopen("trial", "r");
Effect of fseek in a read loop: Given the code that copies from source.txt to target.txt but calls fseek(fs, 4L, SEEK_CUR) after each character read, what will be written to 'target.txt' if the source line is "To err is human"?
C file modes: Given FILE *fp; fp = fopen('NOTES.TXT', 'r+'); which operations on the file are permitted by the mode 'r+' (read/update without truncation)?
What will be the content of 'file.c' after executing the following program? #include
int main() { FILE *fp1, *fp2; fp1=fopen("file.c", "w"); fp2=fopen("file.c", "w"); fputc('A', fp1); fputc('B', fp2); fclose(fp1); fclose(fp2); return 0; }
What will be the output of the program? #include
int main() { int k=1; printf("%d == 1 is" "%s ", k, k==1?"TRUE":"FALSE"); return 0; }
What will be the output of the program? #include
int main() { FILE *ptr; char i; ptr = fopen("myfile.c", "r"); while((i=fgetc(ptr))!=NULL) printf("%c", i); return 0; }
What will be the output of the program? #include
int main() { float a=3.15529; printf("%2.1f ", a); return 0; }
What will be the output of the program? #include
int main() { int a=250; printf("%1d ", a); return 0; }
What will be the output of the program? #include
int main() { FILE *fp; char ch, str[7]; fp=fopen("try.c", "r"); /* file 'try.c' contains "This is Nagpur" */ fseek(fp, 9L, SEEK_CUR); fgets(str, 5, fp); puts(str); return 0; }
What will be the output of the program if value 25 given to scanf()? #include
int main() { int i; printf("%d ", scanf("%d", &i)); return 0; }
What will be the output of the program? #include
int main() { FILE *fp; unsigned char ch; /* file 'abc.c' contains "This is CuriousTab " */ fp=fopen("abc.c", "r"); if(fp == NULL) { printf("Unable to open file"); exit(1); } while((ch=getc(fp)) != EOF) printf("%c", ch); fclose(fp); printf(" ", ch); return 0; }
What will be the output of the program? #include
int main() { printf("%c ", ~('C'*-1)); return 0; }
What will be the output of the program? #include
int main() { char *p; p="%d "; p++; p++; printf(p-2, 23); return 0; }
1
2