Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 51–60 of 303
Topics in C Programming
Q.51 Easy Dynamic Memory
How much memory is allocated by malloc(sizeof(int) * 10) on a 32-bit system where sizeof(int) = 4?
A 10 bytes
B 40 bytes
C 4 bytes
D 44 bytes
Correct Answer:  B. 40 bytes
EXPLANATION

sizeof(int) * 10 = 4 * 10 = 40 bytes on a 32-bit system.

Take Test
Q.52 Easy Dynamic Memory
Which function is used to free dynamically allocated memory?
A delete()
B release()
C free()
D unalloc()
Correct Answer:  C. free()
EXPLANATION

free() is the standard function to deallocate memory previously allocated by malloc(), calloc(), or realloc().

Take Test
Q.53 Easy Dynamic Memory
What does calloc() do differently from malloc()?
A Allocates more memory
B Initializes memory to zero
C Allocates memory faster
D Returns integer instead of void pointer
Correct Answer:  B. Initializes memory to zero
EXPLANATION

calloc() takes two arguments (number of elements and size) and initializes all allocated bytes to zero, unlike malloc().

Take Test
Q.54 Easy Dynamic Memory
Which header file is required for dynamic memory allocation functions?
A
B
C
D
Correct Answer:  B.
EXPLANATION

The <stdlib.h> header file contains declarations for malloc(), calloc(), realloc(), and free() functions.

Take Test
Q.55 Easy Dynamic Memory
What is the return type of malloc() function?
A int*
B void*
C char*
D NULL
Correct Answer:  B. void*
EXPLANATION

malloc() returns a void pointer (void*) that can be cast to any pointer type.

Take Test
Q.56 Easy Dynamic Memory
Which function is used to allocate memory dynamically in C?
A malloc()
B alloc()
C allocate()
D memalloc()
Correct Answer:  A. malloc()
EXPLANATION

malloc() is the standard C function for dynamic memory allocation. It returns a void pointer to the allocated memory.

Take Test
Q.57 Easy File Handling
In a file processing application, what is the primary difference between 'wb' and 'w' file modes?
A 'wb' opens in binary mode while 'w' opens in text mode
B 'w' is faster than 'wb'
C 'wb' allows reading while 'w' does not
D There is no difference in modern C compilers
Correct Answer:  A. 'wb' opens in binary mode while 'w' opens in text mode
EXPLANATION

'w' opens file in text mode (converts line endings), while 'wb' opens in binary mode (no conversion). This matters when handling platform-specific line endings (\r\n vs \n).

Take Test
Q.58 Easy File Handling
Which function is used to check if the end-of-file (EOF) has been reached in C file handling?
A feof(fp)
B eof(fp)
C iseof(fp)
D checkeof(fp)
Correct Answer:  A. feof(fp)
EXPLANATION

feof() is the standard C library function that returns non-zero if EOF has been reached on the given file stream. Other options are not valid C functions.

Take Test
Q.59 Easy File Handling
Which mode opens file in text format with write permission only?
A wb
B w
C wt
D wa
Correct Answer:  B. w
EXPLANATION

'w' mode opens file in text format for writing. 'wb' is binary write. 'wt' is explicitly text write but 'w' is default text mode.

Take Test
Q.60 Easy File Handling
Which function returns the current position of file pointer?
A fgetpos()
B ftell()
C fseek()
D rewind()
Correct Answer:  B. ftell()
EXPLANATION

ftell() returns the current file position as a long integer. fgetpos() stores position in a fpos_t structure. rewind() resets to beginning.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips