Computer Knowledge
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
309 Questions 5 Topics Take Test
Advertisement
Showing 41–50 of 309 questions
Q.41 Hard C Programming
What will be the output of: int x = 5; printf("%d", ++x);?
A 5
B 6
C 7
D Undefined
Correct Answer:  B. 6
Explanation:

The pre-increment operator (++x) increments x from 5 to 6 before using its value in printf(). So the output is 6.

Take Test
Q.42 Hard C Programming
Consider a pointer ptr pointing to an integer array. What does ptr[2] represent?
A The address of the third element
B The value of the third element
C The pointer itself
D The size of the array
Correct Answer:  B. The value of the third element
Explanation:

ptr[2] is equivalent to *(ptr+2), which dereferences the pointer and returns the value at the third element (index 2).

Take Test
Q.43 Hard C Programming
What is the time complexity of searching for an element in an unsorted array using linear search?
A O(1)
B O(log n)
C O(n)
D O(n²)
Correct Answer:  C. O(n)
Explanation:

Linear search checks each element sequentially. In the worst case, it needs to check all n elements, resulting in O(n) time complexity.

Take Test
Q.44 Hard C Programming
What will be the result of executing: int a = 5, b = 10; int *ptr = &a; ptr = &b; printf("%d", *ptr);?
A 5
B 10
C Address of b
D Compilation error
Correct Answer:  B. 10
Explanation:

ptr is reassigned to point to b. When we dereference ptr using *ptr, we get the value stored at b, which is 10.

Take Test
Q.45 Hard C Programming
Which of the following statements about static variables is TRUE?
A Static variables are re-initialized every function call
B Static variables retain their value between function calls
C Static variables cannot be used in functions
D Static variables are automatically deallocated
Correct Answer:  B. Static variables retain their value between function calls
Explanation:

Static variables are initialized only once and retain their value throughout the program execution. Their value persists between function calls.

Take Test
Advertisement
Q.46 Easy C Programming
What is the size of an integer variable in most modern C compilers?
A 2 bytes
B 4 bytes
C 8 bytes
D It depends on the compiler
Correct Answer:  B. 4 bytes
Explanation:

On most modern 32-bit and 64-bit systems, an int is typically 4 bytes (32 bits). However, the exact size can vary depending on the compiler and system architecture.

Take Test
Q.47 Easy C Programming
Which of the following is NOT a valid C data type?
A float
B boolean
C double
D char
Correct Answer:  B. boolean
Explanation:

C does not have a built-in boolean data type. The other options (float, double, char) are all valid primitive data types in C. Boolean functionality is typically implemented using int (0 for false, non-zero for true).

Take Test
Q.48 Easy C Programming
What is the purpose of the & operator in C?
A Bitwise AND operation
B Address-of operator
C Both A and B
D Logical AND operation
Correct Answer:  C. Both A and B
Explanation:

The & operator has two uses in C: (1) When used before a variable, it returns the memory address of that variable (address-of operator), and (2) When used between two integers, it performs a bitwise AND operation.

Take Test
Q.49 Easy C Programming
Which keyword is used to create a constant variable in C?
A final
B constant
C const
D static
Correct Answer:  C. const
Explanation:

The const keyword is used in C to declare a constant variable whose value cannot be modified after initialization. Variables declared as const are read-only.

Take Test
Q.50 Medium C Programming
What will be the memory size of the following struct?
struct Point { int x; char c; int y; }
A 9 bytes
B 10 bytes
C 12 bytes
D 16 bytes
Correct Answer:  C. 12 bytes
Explanation:

Due to memory alignment/padding: int x (4 bytes), char c (1 byte) + 3 bytes padding, int y (4 bytes) = 12 bytes total. The compiler adds padding to align data members to their natural boundaries for efficient memory access.

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