- What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d\n", *(ptr + 2));
return 0;
}
a) 1
b) 2
c) 3
d) 4
**Answer: c) 3**
122. Which function is used to find the largest integer not greater than x in C?
a) ceil() b) floor() c) round() d) trunc() **Answer: b) floor()**
123. What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d\n", x < y ? x++ : y++);
printf("%d\n", x);
printf("%d\n", y);
return 0;
}
a) 5, 6, 10
b) 5, 6, 11
c) 5, 5, 10
d) 5, 5, 11
**Answer: a) 5, 6, 10**
124. Which of the following is used to access the last element of an array in C?
a) arr[length - 1] b) arr[length] c) arr[length + 1] d) arr[-1] **Answer: a) arr[length - 1]**
125. What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Hello";
printf("%c\n", str[5]);
return 0;
}
a) H
b) e
c) l
d) \0
**Answer: d) \0**
126. Which header file is required to use the pow() function in C?
a) <stdio.h> b) <stdlib.h> c) <math.h> d) <ctype.h> **Answer: c) <math.h>**
127. What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
x ^= y;
y ^= x;
x ^= y;
printf("x = %d, y = %d\n", x, y);
return 0;
}
a) x = 5, y = 10
b) x = 10, y = 5
c) x = 0, y = 0
d) Compiler error
**Answer: b) x = 10, y = 5**
128. What does the isdigit() function in C do?
a) Checks if a character is a digit b) Converts a character to its lowercase equivalent c) Converts a character to its uppercase equivalent d) Checks if a character is a whitespace character **Answer: a) Checks if a character is a digit**
129. What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d\n", x++);
printf("%d\n", ++x);
return 0;
}
a) 5, 7
b) 5, 6
c) 6, 6
d) 6, 7
**Answer: b) 5, 6**
130. In C, what is the purpose of the goto statement?
a) To exit a loop b) To transfer control to a labeled statement c) To skip the remaining code in a loop and continue with the next iteration d) To terminate the program **Answer: b) To transfer control to a labeled statement**

Comments