NEW
Font size
WorksheetsC programming quiz 1
Total questions: 20
Worksheet time: 10mins
Which of the following is NOT a valid C data type?
int
float
real
char
What is the size of int in most 32-bit compilers?
1 byte
2 bytes
4 bytes
8 bytes
Which operator has the highest precedence?
+
*
=
&&
What is the output of 5 / 2 in C?
2.5
2
3
2.0
Which operator is used to access the value stored at an address?
&
%
->
*
Which keyword is used for a multiway branching statement?
if
for
switch
goto
What will be the output of this code?
int a = 10;
if(a > 5)
printf("Yes");
else
printf("No");
Yes
No
Error
Nothing
How many times will this run?
for(int i=0; i<5; i++)
4
5
6
Infinite
Which loop must execute at least once?
for
while
do-while
None
Arrays in C are __________
Dynamically sized
Always 1-indexed
Collection of different data types
Collection of similar data types
What is the index of the first element in an array?
0
1
depends on compiler
none
What will this print?
int arr[5] = {1,2,3,4,5};
printf("%d", arr[2]);
1
2
3
4
Which operator checks equality?
=
==
!=
:=
What will be the output?
int a = 3;
printf("%d", a++);
3
4
Compile error
0
Which operator is used for logical AND?
&
&&
|
||
Which is a valid array declaration?
int arr();
arr[10] int;
array int[10];
int arr[10];
What is the output?
int x = 10, y = 20;
printf("%d", x > y);
0
1
10
20
Which of the following is NOT a loop in C?
for
iterate
while
do-while
What is the datatype of 'A' in C?
string
int
char
float
What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {2, 4, 6, 8, 10};
int i, sum = 0;
for(i = 0; i < 5; i++) {
arr[i] = arr[(i + 2) % 5] - arr[i];
sum += arr[i];
}
printf("%d", sum);
return 0;
}
4
6
-4
-6
