Home Subjects Computer Knowledge

Computer Knowledge

Programming, networking, database and OS questions

309 Q 2 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 261–270 of 309
Topics in Computer Knowledge
All C Programming 200 Database/SQL 100
Q.261 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.262 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.263 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.264 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.265 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.266 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.267 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.268 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.269 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.270 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
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