Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Library Functions Questions
C standard I/O library: what does rewind(stream) do to a file stream? Choose the most accurate behavior per ISO C for a valid open stream.
C strings: which standard library function finds the last occurrence of a character in a string? Pick the correct function name used to search from the end.
C headers: in which header are input/output function prototypes and macros defined? Choose the correct standard header for stdio APIs.
C stdio: can fprintf be used to display output on the screen? If yes, how would you direct output to the console?
C standard streams: what is stderr? Choose the most accurate description used in ISO C.
C stdio buffers: what is the purpose of fflush? Choose the best description of how fflush operates on streams.
Turbo C (DOS): what does randomize() do? Legacy compiler question about seeding the pseudo-random generator.
C conversion utilities: does a function exist to convert int or float to a string (text)? Answer with the standard-library perspective and common practice.
In C, what does this code print when comparing only the first two bytes? #include
#include
int main() { char dest[] = {97, 97, 0}; // "aa\0" char src[] = "aaa"; // "aaa\0" int i; if ((i = memcmp(dest, src, 2)) == 0) printf("Got it"); else printf("Missed"); return 0; } Choose the observed output.
In C, scanf returns the number of successful assignments. What does this program print (assume the user types two valid integers)? #include
int main() { int i; i = scanf("%d %d", &i, &i); printf("%d ", i); return 0; }
Consider the following C code using math.h: #include
#include
int main() { float i = 2.5; printf("%f, %d", floor(i), ceil(i)); return 0; } What output is most consistent with typical platform behavior, noting the incorrect format specifier for ceil?
In the C standard library, what does the function gcvt do?
In C, printf returns the number of characters written. What does this program print (conceptual order of outputs)? #include
int main() { int i; i = printf("How r u "); i = printf("%d ", i); printf("%d ", i); return 0; } Assume a standard ASCII environment.
In C, what happens with ungetc and which stream does it apply to? Consider the program below when the user provides the character 'b' as input each time. #include
int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'b' */ ungetc(c, stdout); printf("%c", c); ungetc(c, stdin); } return 0; } Choose the best description of the visible output.
Predict the output when using ungetc correctly on stdin. The user repeatedly inputs the character 'a': #include
int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; } What is printed?
In C, what will this program print? #include
#include
int main() { char *i = "55.555"; int result1 = 10; float result2 = 11.111f; result1 = result1 + atoi(i); result2 = result2 + atof(i); printf("%d, %f", result1, result2); return 0; } Assume default float formatting with six digits after the decimal.