Which of the following is used to declare a constant in C?
Answer: B
In C, the 'const' keyword is used to declare constants. Once a const variable is initialized, its value cannot be changed. Options A, C, and D are not valid C syntax.
Q.82Easy
What is the purpose of the return statement in a C function?
Answer: B
The return statement is used to exit a function and return a value (if any) to the calling function. If the function has return type void, no value is returned.
Q.83Medium
What will be the output of: int x = 5; x += 3; printf("%d", x);?
Answer: B
The operator += means x = x + 3. So x = 5 + 3 = 8. The printf statement outputs 8.
Q.84Medium
Which loop in C does NOT check the condition before executing the loop body?
Answer: C
The do-while loop executes the loop body at least once before checking the condition. Other loops check the condition before execution. Syntax: do { } while(condition);
Q.85Medium
What will be the output of: int x = 5; int y = ++x; printf("%d %d", x, y);?
Answer: B
The pre-increment operator (++x) increments x first, then assigns it. So x becomes 6, and y is assigned 6. Output: 6 6.
Advertisement
Q.86Medium
Which function is used to allocate memory dynamically in C?
Answer: B
malloc() (memory allocation) is used to dynamically allocate memory on the heap in C. It requires #include <stdlib.h>. new() is used in C++, not C.
Q.87Medium
What is the output of: int a = 10, b = 20; int temp = a; a = b; b = temp; printf("%d %d", a, b);?
Answer: B
This is a swap operation. Initially a=10, b=20. After temp=a (temp=10), a=b (a=20), b=temp (b=10). Output: 20 10.
Q.88Medium
In C, what does the scanf() function do?
Answer: B
scanf() reads formatted input from the standard input device (usually keyboard). printf() displays output. Both require #include <stdio.h>.
Q.89Medium
What will be the output of: for(int i = 0; i < 3; i++) { printf("%d ", i); }?
Answer: A
Loop runs with i=0,1,2. When i=3, condition i<3 becomes false and loop terminates. Output: 0 1 2 (with spaces).
Q.90Medium
Which of the following is the correct way to define a function that takes no parameters and returns no value?
Answer: A
In C, void function() { } is correct. In some contexts, void function(void) { } is more explicit. Options B and C use invalid keywords for this purpose.
Q.91Medium
What is the output of the following program: int x = 5; if(x > 3) printf("Greater"); else printf("Smaller");?
Answer: B
x=5 is greater than 3, so the condition (x > 3) evaluates to true. The if block executes, printing 'Greater'.
Q.92Hard
In C, when passing arrays to functions, what is actually passed?
Answer: B
When an array is passed to a function in C, it decays to a pointer pointing to the first element. This is why changes made in the function affect the original array.
Q.93Hard
What will be the output of: int a = 5; int *p = &a; printf("%d %d", a, *p);?
Answer: B
p is a pointer storing the address of a. *p (dereferencing) gives the value at that address, which is 5. So both a and *p print 5.
Q.94Easy
Which header file is required for using the printf() function?
Answer: B
stdio.h (Standard Input/Output header) contains declarations for printf(), scanf(), and other I/O functions.
Q.95Easy
What is the correct syntax to declare a constant in C?
Answer: D
Both 'const int x = 10;' and 'int const x = 10;' are valid ways to declare constants in C. The const keyword can appear before or after the type.
Q.96Easy
Which operator is used to access the value at an address in C?
Answer: B
The * operator is the dereference operator that accesses the value at a memory address. The & operator gets the address of a variable.
Q.97Easy
What does the sizeof() operator return?
Answer: B
sizeof() is a unary operator that returns the number of bytes occupied by a variable or data type in memory.
Q.98Easy
Which of the following is a correct way to initialize a 1D array in C?
Answer: D
All three methods are valid. Option A initializes with size 5, option B auto-determines size from initialization, and option C declares without initialization.
Q.99Medium
What is the return type of the malloc() function?
Answer: B
malloc() returns a void pointer (void*) which can be cast to any pointer type. It returns NULL if memory allocation fails.
Q.100Medium
Which function is used to release dynamically allocated memory in C?
Answer: B
The free() function deallocates memory that was previously allocated using malloc(), calloc(), or realloc(). delete() is used in C++.