wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Joy of Programming

Total questions: 50

Worksheet time: 17mins

Name
Class
Date
1.
Which of the following is not a valid C variable name?
a)
int number;
b)
float rate;
c)
int variable_count
d)
int $main
2.
Which data type is most suitable for storing a number 65000 in a 32-bit system?
a)
signed short
b)
unsigned short
c)
long
d)
int
3.
The format identifier ‘%i’ is also used for _____ data type?
a)
char
b)
int
c)
float
d)
double
4.
What is the size of an int data type?
a)
4 byte
b)
8bytes
c)
Depends on compiler
d)
cannot be deter
5.
Which of the following cannot be checked in a switch case statement ?
a)
char
b)
int
c)
Enum
d)
float
6.
We cannot use String in the Switch case as label
a)
Yes
b)
No
7.
Nesting of if-else statements is allowed in C Programming.
a)
Yes
b)
No
8.
Continue statement is allowed inside the switch case statement ?
a)
Yes
b)
No
9.
For loop is _________.
a)
Function Controlled
b)
Entry Controlled
c)
Exit Controlled
d)
None
10.
Comment on the output of this C code?
 int main()
  {
 float f1 = 0.1;
  if (f1 == 0.1)
  printf("equal\n");
  else
  printf("not equal\n");
  }
a)
equal
b)
not equal
c)
depends on compiler
d)
None
11.
Which of the datatypes have size that is variable?
a)
int
b)
struct
c)
float
d)
double
12.
What is the size of float in a 32-bit compiler?
a)
2
b)
4
c)
8
d)
16
13.
Which data type is suitable for storing a number like?
  10.0000000001
a)
int
b)
float
c)
do
d)
both float & double 
14.
Predict output
  void main()
  {    
float x = 0.1;
  printf("%d, ", x);
  printf("%f", x);
  }
a)
0.100000 , junk value
b)
junk value, 0.100000
c)
0, 0.100000
d)
0, 0.999999
15.
What will be the data type of the result of the following operation?
 (float)a*(int)b/(long)c * (double)d
a)
int
b)
long
c)
float
d)
do
16.
What is the output of this C code?
int main()
{
int var = 010;
printf("%d", var);
}
a)
2
b)
8
c)
010
d)
10
17.
The value obtained in the function is given back to main by using ________ keyword?
a)
return
b)
static
c)
new
d)
volatile
18.
What will be the data type returned for the following function?
  int func()
  {
 return (double)(char)5.0;
  }
a)
char
b)
int
c)
double
d)
Return illegal
19.
functions can return structure in c?
a)
True
b)
False
20.
functions can return enumeration constants in c?
a)
True
b)
False
21.
Which keyword is used to prevent any changes in the variable within a C program?
a)
immuta
b)
mutable
c)
const
d)
vola
22.
The name of the variable used in one function cannot be used in another function?
a)
True
b)
False
23.
variable declared in a function can be used in main?
a)
True
b)
False
24.
 #include is called
a)
Preprocessor directive
b)
Inclusion directive
c)
File inclusion directive
d)
None
25.
 Preprocessor feature that supply line numbers and file names to compiler is called?
a)
Selective inclusion
b)
macro substitution
c)
Concatenation
d)
Line control
26.

Pick the odd man out

a)

import

b)

pass

c)

break

d)

continue

27.

List is represented by

a)

{ }

b)

[ ]

c)

( )

d)

< >

28.

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?

a)

[3, 4, 5, 20, 5, 25, 1, 3]

b)

[1, 3, 3, 4, 5, 5, 20, 25]

c)

[3, 5, 20, 5, 25, 1, 3]

d)

[1, 3, 4, 5, 20, 5, 25]

29.

List is Mutable

a)

YES

b)

NO

30.

A reserved keyword may not be chosen as an identifier

a)

True

b)

False

31.

Which operator is called as equality operator?

a)

- *

b)

==

c)

- +

d)

=

32.

Python ____________ holds key-value pairs.

a)

Set

b)

Tuple

c)

Dictionary

d)

List

33.

Which keyword is use for function?

a)

define

b)

fun

c)

def

d)

function

34.

mylist = ["apple", “Orange", "cherry"]

x = len(mylist)

What is the value of x?

a)

2

b)

4

c)

1

d)

3

35.

List = [1, 2, 3, 1, 2, 1, 2, 3, 2, 1]

print(List.count(1))

a)

4

b)

3

c)

2

d)

1

36.

What is a recursive function?

a)

A function that calls other function

b)

A function which calls itself.

c)

Both A and B

d)

None

37.

List = [2.3, 4.445, 3, 5.33, 1.054, 2.5]

print(List.pop(0))

Which value will be popped out?

a)

2.5

b)

2.3

c)

3

d)

None

38.

Which one of the following is the correct way of calling a function?

a)

function_name()

b)

call function_name()

c)

ret function_name()

d)

function function_name()

39.

Which operator is used to perform mod operation?

a)

%

b)

*

c)

+

d)

&

40.

Lambda is a function in python?

a)

Yes

b)

No

41.

What is a variable defined outside a function referred to as?

a)

local variable

b)

global variable

c)

static Variable

d)

automatic variable

42.

__________ is a general-purpose array-processing package

a)

NumPy

b)

exception

c)

ArrayNum

d)

NumPython

43.

Which of the following statements is not related to list?

a)

[ ]

b)

unmutable

c)

mutable

d)

Dynamic array

44.

Type code for Int in array concept

a)

f

b)

i

c)

int

d)

num

45.

n = 10

sum = 0 i = 1

while i <= n:

sum = sum + i

i = i+1

print("The sum is", sum)

What is the Result?

a)

55

b)

45

c)

100

d)

200

46.

Pick odd man out

a)

set

b)

tuple

c)

list

d)

array

47.

The ____________ statement is a null statement

a)

pass

b)

asert

c)

break

d)

continue

48.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

49.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

50.
An if statement must evaluate to:
a)
Right or Wrong
b)
True
c)
True or False
d)
False