Computer Knowledge — C Programming
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
200 Questions 5 Topics Take Test
Advertisement
Showing 31–40 of 200 questions in C Programming
Q.31 Medium C Programming
What is the correct way to declare a function that takes no parameters and returns an integer?
A int func();
B int func(void);
C func() returns int;
D int func(no parameters);
Correct Answer:  B. int func(void);
Explanation:

To explicitly declare a function with no parameters in C, use 'void' as the parameter. int func(); is ambiguous in older C standards.

Take Test
Q.32 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.33 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.34 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.35 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
Advertisement
Q.36 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
Q.37 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.38 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.39 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.40 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
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