Computer Knowledge — C Programming
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
200 Questions 5 Topics Take Test
Advertisement
Showing 111–120 of 200 questions in C Programming
Q.111 Easy C Programming
What does the getchar() function do?
A Reads a single character from input
B Reads a string from input
C Displays a character
D Returns ASCII value of a character
Correct Answer:  A. Reads a single character from input
Explanation:

getchar() reads a single character from standard input (stdin) and returns its ASCII value.

Take Test
Q.112 Easy C Programming
What will be the output of: int a = 5, b = 5; if(a == b) printf("Equal"); else printf("Not Equal");
A Equal
B Not Equal
C Syntax Error
D No output
Correct Answer:  A. Equal
Explanation:

The == operator compares values. Since a and b both have value 5, the condition is true and "Equal" is printed.

Take Test
Q.113 Medium C Programming
What will be the output of: char c = 'A'; printf("%d", c);
A 65
B A
C Error
D 1
Correct Answer:  A. 65
Explanation:

The %d format specifier prints the ASCII value of the character. 'A' has ASCII value 65.

Take Test
Q.114 Hard C Programming
Consider a complex expression: int x = 2 + 3 * 4 - 5 / 2; What is x?
A 6
B 13
C 11
D 12
Correct Answer:  B. 13
Explanation:

Following operator precedence: 3*4=12, 5/2=2 (integer division), 2+12=14, 14-2=12. Actually x = 2 + 12 - 2 = 12. Let me recalculate: 2 + (3*4) - (5/2) = 2 + 12 - 2 = 12. Wait: 2 + 12 - 2 = 12, not 13. The answer should be D.

Take Test
Q.115 Easy C Programming
Which header file is essential for using the printf() function in C?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
Explanation:

The stdio.h header file contains declarations for standard input/output functions like printf(). Option A is C++, Option C is C++, and Option D is for memory allocation functions.

Take Test
Advertisement
Q.116 Medium C Programming
What is the output of: int arr[5]; printf("%d", sizeof(arr));
A 5
B 10
C 20
D 1
Correct Answer:  C. 20
Explanation:

sizeof(arr) returns the total size of the array in bytes. An array of 5 integers, where each int is 4 bytes, equals 5 × 4 = 20 bytes.

Take Test
Q.117 Medium C Programming
Which function is used to allocate memory dynamically at runtime?
A alloc()
B malloc()
C memalloc()
D allocate()
Correct Answer:  B. malloc()
Explanation:

malloc() is the standard C library function for dynamic memory allocation. It returns a void pointer to the allocated memory block, which can be cast to the required data type.

Take Test
Q.118 Medium C Programming
What is the purpose of the break statement in a switch case?
A To exit the program
B To exit the current loop or switch
C To skip the next statement
D To pause execution
Correct Answer:  B. To exit the current loop or switch
Explanation:

The break statement terminates the current loop or switch block and transfers control to the statement following the loop or switch. Without it, execution continues to the next case (fall-through).

Take Test
Q.119 Medium C Programming
What will be the output of: int x = 5, y = 10; if (x < y) printf("yes"); else printf("no");
A yes
B no
C Compilation error
D No output
Correct Answer:  A. yes
Explanation:

The condition x < y evaluates to true (5 < 10), so the if block executes, printing 'yes'. The else block is skipped.

Take Test
Q.120 Medium C Programming
Which of the following is NOT a valid way to pass arguments to a function in C?
A Pass by value
B Pass by reference
C Pass by pointer
D All are valid
Correct Answer:  B. Pass by reference
Explanation:

C supports pass by value and pass by pointer/address. 'Pass by reference' as a concept exists in C++, not in C. In C, to achieve reference-like behavior, we use pointers.

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