iGET

C Programming - MCQ Practice Questions

Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

978 questions | 100% Free

Q.381Medium

A file opened with 'r+b' mode has pointer at position 100. After fwrite(buffer, 1, 50, fp), the pointer is at:

Q.382Medium

Which approach correctly implements a file copy function for both text and binary files?

Q.383Medium

A program crashes after reading a file. What's most likely the cause if error checking is minimal?

Q.384Medium

For a file with 1000 records, which approach minimizes I/O operations?

Q.385Medium

A program needs to read and write to the same file alternately. Which file mode is most appropriate?

Q.386Medium

What will be the output of fseek(fp, -10, SEEK_END) in a file of 100 bytes?

Q.387Medium

In a data structure serialization scenario, what is returned by fwrite() on successful completion?

Q.388Medium

A competitive exam question requires processing a 500MB CSV file line by line. Which approach is most efficient in terms of memory?

Q.389Medium

What is the critical issue if ferror(fp) returns non-zero during file operations in a banking application?

Q.390Medium

What will be the output of the following code? int *ptr = malloc(sizeof(int)); if(ptr == NULL) printf("Failed"); else printf("Success");

Q.391Medium

What is a memory leak in C?

Q.392Medium

What happens when you try to access memory after calling free()?

Q.393Medium

What is the purpose of realloc() function?

Q.394Medium

Which of the following is correct for dynamic array allocation?

Q.395Medium

What is double free error?

Q.396Medium

Analyze this code: char *str = malloc(5); strcpy(str, "Hello"); How many bytes should malloc allocate for safety?

Q.397Medium

What is the output? int *p = malloc(sizeof(int) * 3); p[0] = 1; p[1] = 2; p[2] = 3; printf("%d", *(p+2));

Q.398Medium

Which of the following correctly allocates memory for an array of 5 strings (each max 20 characters)?

Q.399Medium

What is the purpose of typecasting in malloc()? int *p = (int*)malloc(sizeof(int));

Q.400Medium

Analyze the memory leak in this code: void func() { int *p = malloc(100); if(condition) return; free(p); }