NEW
Font size
WorksheetsCoding Club Quizz
Total questions: 50
Worksheet time: 25mins
Identify the syntax error in C:
int a = 10
printf("%d",a);
Missing semicolon
Wrong printf
Wrong data type
No error
Which is correct variable initialization in Python?
int a = 5
a = 5
a := 5
define a = 5
Output?
print("Hello")
Hello
"Hello"
Error
None
Which is a valid C++ variable name?
1num
num_1
num-1
int
Which symbol ends a C statement?
:
;
.
,
Which data type is used for decimal numbers in C?
int
float
Output?
int a=5;
printf("%d",a);
5
a
Error
0
Which keyword defines a function in Python?
define
def
func
function
Output?
cout << 10*2;
20
10
10*2
Error
Which operator checks equality?
=
==
!=
<=
SECTION 2: CONDITIONALS & LOOPS Output?
int a=3;
a++;
printf("%d",a);
3
4
5
Error
SECTION 2: CONDITIONALS & LOOPS :
Output?
x=4
4
0
No output
Error
if x>2:
print("Yes")
else:
print("No")
Yes
No
Error
Nothing
Which loop executes at least once in C?
for
while
do-while
foreach
Output?
int a=10;
if(a>5)
cout<<"Pass";
Pass
Fail
No Output
Error
Output?
for i in range(3):
print(i)
0 1 2
1 2 3
0 1 2 3
Error
Find the error:
for i in range(5)
print(i)
Missing colon
Indentation error
No error
Wrong range
Output?
switch(2){
case 1: cout<<"One";
break;
case 2: cout<<"Two";
break;
default:
cout<<"Other"; }
One
Two
Other
Error
Output?
int a=5,b=10;
printf("%d",a>b?a:b);
5
10
0
Error
Identify error:
if True:
print("Hi")
Indentation error
Syntax error
No error
Name error
Output?
int arr[3]={1,2,3};
printf("%d",arr[1]);
1
2
3
Output?
x=[1,2,3]
x.append(4)
print(len(x))
3
4
5
Error
Output?
cout<<5+2*3;
21
11
17
Error
Output?
char ch='A';
printf("%d",ch);
A
65
Error
97
Output?
string s="Hello";
cout<<S;
4
5
6
Error
Output?
print("Hi"*3)
HiHiHi
Hi 3
Error
Hi*3
printf("%d",a<<1);
2
4
6
8
Output?
int i;
for(i=1;i<=5;i+=2)
printf("%d",i);
1 3 5
1 2 3 4 5
2 4
Error
Output?
x="coding"
print(x[1:4])
cod
odi
ding
Error
Output?
int a=5;
cout<<a++<<" "<<a;
5 6
6 6
5 5
Error
Output?
int *p;
int a=10;
p=&a;
printf("%d",*p);
10
Address of a
Error
0
Output?
int a=5,b=3;
printf("%d",a&b);
1
5
7
0
Output?
int a=5,b=3;
printf("%d",a&b);
10
20
Error
0
Output?
def f(x=[]):
x.append(1)
print(x)
f()
f()
[1] [1]
[1] [1,1]
Error
[1,1] [1]
Output?
int i=5;
do{
printf("%d",i);
i--;
}while(i>5);
5
54321
No output
Error
Output?
char str[]="HELLO";
cout<<str+2;
HELLO
LLO
ELLO
LO
Output?
print(bool("0"))
True
False
Error
0
Output?
int arr[3]={1,2,3};
printf("%d",(arr+1));
1
2
3
Error
Output?
int i=0;
printf("%d %d", i++, ++i);
0 2
1 1
0 1
Undefined Behavior
Output?
int a=3;
printf("%d", a*-2+1);
6
9
5
Error
Output?
x=(1,2,3)
print(x[::-1])
(3,2,1)
(1,2,3)
[3,2,1]
Error
Output?
int x=10;
printf("%d", x/3);
3
3.33
3.0
Error
Output?
int a=0;
for(;a<5;){
cout<<a;
a+=2;
}
024
01234
135
Error
Output?
int a=5;
cout<< ++a + a++;
11
12
13
Undefined Behavior
Output?
printf((5>3) and (2<1))
True
False
Error
None
SECTION 5: VERY HARD
Output?
int a=1;
cout<<(a<<2);
2
4
8
Output?
def fact(n):
if n==0:
return 1
return n*fact(n-1)
print(fact(4))
12
24
16
Error
Output?
int a=5,b=2;
printf("%d",a/b);
2
2.5
3
Error
Output?
string s="ABCDE";
cout<<s.substr(1,3);
ABC
BCD
CDE
Error
Output?
x=5
y=lambda x:x*2
print(y(3))
6
10
8
Error
