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