d d d d d d d d d d
#include <stdio.h> d
int main() { printf("Hello
d d d
, world!");return 0;
d d d
}
A. Hello, world! d
B. Hello
C. world
D. Compile-
time errorAnswer: A.
d d d
2. Which of the following is NOT a valid C identifier?
d d d d d d d d d d
A. my_var
B. _myVar
C. 1_myvar
D. myVar1 d
Answer: C. d
3. What is the output of the following C code snippet?ar
d d d d d d d d d d d
duino
#include <stdio.h> d
int main() {
d d d
int x = 5;
d d d
printf("%d", x++); d
printf("%d", x); d d
return 0; d
}
A. 56
B. 55
C. 65
D. 6 Answ
d
er: A.
d
4. Which of the following is the correct syntax for declaring a function t
d d d d d d d d d d d d d
hat takes two integer parameters and returns an integer?
d d d d d d d d
A. intmyFunction(int x, int y) { return x + y; } d d d d d d d d d
B. function(int x, int y) int { return x + y; } d d d d d d d d d d
C. int function myFunction(int x, int y) { return x + y; }
d d d d d d d d d d d
D. int myFunction(int x int y) { return x + y; }
d d d d d d d d d d d
Answer: A. d
5. What is the output of the following C code snippet?
d d d d d d d d d d
,#include <stdio.h> d
int main() {
d d
int arr[] = {1, 2, 3, 4, 5};
d d d d d d d
printf("%d", arr[2]); d d
return 0; d
}
A. 1
B. 2
C. 3
D. 4 Answ d
er: C.
d
6. Which of the following operators can be used to obtain the addressof a
d d d d d d d d d d d d d d
variable in C?
d d d
A. &
B. *
C. +d
D. -d
dAnswer: A d
.
7. What is the output of the following C code snippet?
d d d d d d d d d d
#include <stdio.h> d
int main() {
d d
int x = 5, y = 7; printf("%d"
d d d d d d d
, x > y ? x : y);return 0;
d d d d d d d d d
}
A. 5
B. 7
C. 12
D. Compile-
time errorAnswer: B.
d d d
8. Which of the following statements about arrays in Cis FALSE?
d d d d d d d d d d
A. An array is a collection of elements of the same data type.
d d d d d d d d d d d
B. The size of an array must be specified at the time of declaration.
d d d d d d d d d d d d
C. The index of the first element of an array is always 0.
d d d d d d d d d d d
D. The elements of an array can be of different data types.A
d d d d d d d d d d d
nswer: D. d
9. What is the output of the following C code snippet?ar
d d d d d d d d d d d
duino
,#include <stdio.h> d
int main() {
d d
int arr[] = {1, 2, 3, 4, 5};
d d d d d d d
int *p = arr; printf("%d
d d d d
", *(p + 3));return 0;
d d d d d
}
A. 1
B. 2
C. 3
D. 4 Answ d
er: D.
d
10.Which of the following is the correct syntax for declaring a pointerto
d d d d d d d d d d d d
an integer in C? d d d d
A. int *p; d
B. int p; d
C. *int p; d
D. pointer int p; d d d
Answer: A. d
11.What is the output of the following C code snippet?
d d d d d d d d d
ini
#include <stdio.h> d
int main() { in
d d d
t x = 5; int *
d d d d d
p = &x; d d
*p = 7; printf(" d d d
%d", x);return 0 d d d
;
}
A. 5
B. 7
C. Compile-time error d
D. Run-
time errorAnswerd d
: B.
d
12.Which of the following is the correct syntax for a while loop in C?
d d d d d d d d d d d d d
A. while (condition) { statement; } d d d d
B. while (statement) { condition; } d d d d
C. for (statement; condition; increment) { }
d d d d d
D. do { statement; } while (condition);
d d d d d d
Answer: A. d
, 13.What is the output of the following C code snippet?a
d d d d d d d d d d
rduino
#include <stdio.h> d
int main() {
d d d
int x = 5;i
d d d d
nt y = 7;
d d d
printf("%d", x & y); d d d d
return 0; d
}
A. 0
B. 1
C. 5
D. 7 Answ
d
er: A.
d
14.Which of the following is the correct syntax for a switchst
d d d d d d d d d d d
atement in C? d d
A.
switch (expression) {
d d d
case constant1: state
d d
ment1;
break;
case constant2:d d
statement2; d
break;
default:
statement3;
}
B.
switch (expression)
d d
case constant1:d
statement1; d
break;
case constant2:d d
statement2; d
break;
default:
statement3;
C.