wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AI-Quiz3

Total questions: 109

Worksheet time: 1hrs 24mins

Name
Class
Date
1.
a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error

2.
a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error

3.
a)

GREEN

b)

RABBIT

GREEN

c)

RABBIT is printed unlimited number of times.

d)

Compiler error.

4.
a)

GREEN

b)

RABBIT

GREEN

c)

RABBIT is printed unlimited number of times.

d)

None of the above

5.
a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

6.
a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

7.
a)

compiler error

b)

10 10 10 10 10

c)

10 11 12 13 14 15

d)

None of the above

8.
a)

No Output

b)

TESTING

c)

Compiler error

d)

None of the above

9.
a)

Compiler error

b)

FLOWER FRUITS

c)

FLOWER YELLOW

d)

FLOWER YELLOW FRUITS

10.
a)

Compilation Error

b)

1 2 3 1 2 3

c)

1 1 2 2 3 3

d)

None of the above

11.
a)

99

b)

102

c)

109

d)

None of the above

12.
a)

1 2 3 0

b)

1 1 2 2

c)

2 1 3 0

d)

0 1 2 3

13.
a)

4--6

b)

6--

c)

4--

d)

None of the above

14.
a)

Compilation error

b)

-128

c)

0

d)

1

15.
a)

127

b)

128

c)

Program never ends

d)

0

16.
a)

Nothing prints

b)

for

c)

for for for

d)

None of the above

17.
a)

Compilation error

b)

Program never ends

c)

loop loop loop loop loop

d)

None of these

18.
a)

Compilation error

b)

Program never ends

c)

Hello

d)

None of the above

19.
a)

2 4

b)

No output

c)

2 4 6

d)

Program never ends

20.
a)

Compilation error

b)

1 2 3

c)

4

d)

0 1 2 3

21.

Select different parts of "for" looping statement-

a)

Initialization part

b)

Condition Part

c)

Update part

d)

All of these

22.

What will be the output of following code- for(int i = 1; i < 5; i++ )

{

System.out.print(i);

}

a)

13

b)

135

c)

1234

d)

12345

23.

_________ in programming come into use when we need to repeatedly execute a block of statements.

a)

nested for loop

b)

none

c)

for loop

d)

loop

24.

The __________ statement uses single expression for multiple choices

a)

loop

b)

switch

c)

multiple value

d)

if else

25.

in __________ the controlling condition appears at the start of the loop and _______ at the end of the loop

a)

While / Do while

b)

Do while/While

c)

None

26.
If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? a.  b.  c. . d. 
a)
parentheses ( )
b)
braces { }
c)
brackets [ ]
d)
arrows < >
27.

What is an Array?

a)

A group of elements of same data type.

b)

An array contains more than one element

c)

Array elements are stored in memory in continuous or contiguous locations.

d)

All the above.

28.

In general, the index of the first element in an array is __________

a)

0

b)

-1

c)

2

d)

1

29.

What is meaning of following

declaration ?

int arr[20];

a)

Array of size 20 that can have integer address

b)

Array of Size 20

c)

Integer Array of size 20

d)

None of these

30.

Assuming int is of 2 bytes, what is the size of int arr[15];?

a)

15

b)

19

c)

11

d)

30

31.

What is the length of the following array: int data[] = { 12, 34, 9, 0, -62, 88 };

a)

1

b)

5

c)

6

d)

12

32.

If we have declared an array described below -

int arr[6];

then which of the following array element is considered as last array element ?

a)

arr[6]

b)

arr[4]

c)

arr[0]

d)

arr[5]

33.

All the arithmetic operators operate on (a)   associativity.

34.

The symbol used for conditional operator is _____

a)

?:

b)

=

c)

++

d)

>=

35.

The word algorithm is derived from the following

a)

a. AL-KHOWARIZMI

b)

b. AL-AHMED

c)

c. AL-JAFAR

d)

d. AL-MURA

36.

The special function called ____ is where program execution begins.

a)

a. Add

b)

b. Sub

c)

c. Main

d)

d. Multi

37.

Escape sequence _______ represents bell sound.

a)

a. \n

b)

b. \a 

c)

c. \t

d)

d. \b

38.

The meaning of the operator ______ is modulus in C language.

a)

a. ++

b)

b. mod

c)

c. %

d)

d. *

39.

In the following declaration,

int sum(int , int);

How many parameters are declared?

a)

a. 4

b)

b.6

c)

c. 2

d)

d. 3

40.

Function declaration or function prototype has ____ components.

a)

a. 4

b)

b. 7

c)

c. 9

d)

d. 3

41.

Which loop is faster in C Language, for, while or Do While.?

a)

for

b)

while

c)

do while

d)

All of the given

42.

Choose correct C while loop syntax.

a)

while(condition)

{

//statements

}

b)

{

//statements

}while(condition)

c)

while(condition);

{

//statements

}

d)

while()

{

if(condition)

{

//statements

}

}

43.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation)

{

//statements

}

b)

for(declaration; condition; incrementoperation)

{

//statements

}

c)

for(declaration; incrementoperation; condition)

{

//statements

}

d)

for(initalization; condition; incrementoperation;)

{

//statements

}

44.

Choose a correct C do while syntax.

a)

dowhile(condition)

{

//statements

}

b)

do while(condition)

{

//statements

}

c)

do

{

//statements


}while(condition);

d)

do

{

//statements


}while(condition)

45.

What is the output of C Program.?

int main()

{

while(true)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error.

46.

What is the output of C Program.?

int main()

{ int a=5;

while(a=123)

{ printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT

GREEN

c)

RABBIT is printed unlimited number of times.

d)

Compiler error.

47.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

48.

What is the output of C Program.?

int main()

{

int k;

for(k=1; k <= 5; k++);

{

printf("%d ", k);

}

return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

49.

What is the output of C Program.?

int main()

{ int a=14;

while(a<20)

{ ++a;

if(a>=16 && a<=18)

{ continue; }

printf("%d ", a);

}

return 0;

}

a)

15 16 17 18 19

b)

15 18 19

c)

15 16 20

d)

15 19 20

50.

What is the output of C Program.?

int main()

{

int a=10, b, c;

b=a++;

c=++a;

printf("%d %d %d", a, b, c);

return 0;

}

a)

10 11 12

b)

12 10 12

c)

12 11 12

d)

12 12 12

51.

What is the output of C Program.?

int main()

{

int k;

for(k=1; k <= 5; k++)

{ printf("%d ", k);

}

return 0;

}

a)

1 2 3 4

b)

1 2 3 4 5

c)

6

d)

5

52.

Loops in C Language are implemented using.?

a)

While

b)

Do - While

c)

For

d)

All

53.

Which loop is faster in C Language, for, while or Do While.?

a)

For

b)

While

c)

Do - while

d)

All

54.

What is the output of C Program.?

int main()

{

while(true)

{ printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error.

55.

Choose a correct C do while syntax.

a)

dowhile(condition) { //statements }

b)

do while(condition)

{ //statements }

c)

do { //statements }while(condition)

d)

do { //statements }while(condition);

56.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{ printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

compiler error

d)

25 26

57.

Choose a correct C for loop syntax.

a)

for(initalization; Expression; Update Expression)

{ //statements }

b)

for(declaration; condition; incrementoperation);

{ //statements }

c)

for(declaration; incrementoperation; condition)

//statements

58.

Select different parts of "for" looping statement-

a)

Initialization part

b)

Condition Part

c)

Update part

d)

All of these

59.

What will be the output of following code- for(int i = 1; i < 5; i++ )

{

System.out.print(i);

}

a)

13

b)

135

c)

1234

d)

12345

60.

_________ in programming come into use when we need to repeatedly execute a block of statements.

a)

nested for loop

b)

none

c)

for loop

d)

loop

61.

The __________ statement uses single expression for multiple choices

a)

loop

b)

switch

c)

multiple value

d)

if else

62.

in __________ the controlling condition appears at the start of the loop and _______ at the end of the loop

a)

While / Do while

b)

Do while/While

c)

None

63.
If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? a.  b.  c. . d. 
a)
parentheses ( )
b)
braces { }
c)
brackets [ ]
d)
arrows < >
64.

What is an Array?

a)

A group of elements of same data type.

b)

An array contains more than one element

c)

Array elements are stored in memory in continuous or contiguous locations.

d)

All the above.

65.

In general, the index of the first element in an array is __________

a)

0

b)

-1

c)

2

d)

1

66.

What is meaning of following

declaration ?

int arr[20];

a)

Array of size 20 that can have integer address

b)

Array of Size 20

c)

Integer Array of size 20

d)

None of these

67.

Assuming int is of 2 bytes, what is the size of int arr[15];?

a)

15

b)

19

c)

11

d)

30

68.

The symbol used for conditional operator is _____

a)

?:

b)

=

c)

++

d)

>=

69.

The special function called ____ is where program execution begins.

a)

a. Add

b)

b. Sub

c)

c. Main

d)

d. Multi

70.

Escape sequence _______ represents bell sound.

a)

a. \n

b)

b. \a 

c)

c. \t

d)

d. \b

71.

The meaning of the operator ______ is modulus in C language.

a)

a. ++

b)

b. mod

c)

c. %

d)

d. *

72.

Which loop is faster in C Language, for, while or Do While.?

a)

for

b)

while

c)

do while

d)

All of the given

73.

Choose correct C while loop syntax.

a)

while(condition)

{

//statements

}

b)

{

//statements

}while(condition)

c)

while(condition);

{

//statements

}

d)

while()

{

if(condition)

{

//statements

}

}

74.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation)

{

//statements

}

b)

for(declaration; condition; incrementoperation)

{

//statements

}

c)

for(declaration; incrementoperation; condition)

{

//statements

}

d)

for(initalization; condition; incrementoperation;)

{

//statements

}

75.

Choose a correct C do while syntax.

a)

dowhile(condition)

{

//statements

}

b)

do while(condition)

{

//statements

}

c)

do

{

//statements


}while(condition);

d)

do

{

//statements


}while(condition)

76.

What is the output of C Program.?

int main()

{

while(true)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT

b)

RABBIT is printed unlimited number of times.

c)

No output

d)

Compiler error.

77.

What is the output of C Program.?

int main()

{ int a=5;

while(a=123)

{ printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT

GREEN

c)

RABBIT is printed unlimited number of times.

d)

Compiler error.

78.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

79.

What is the output of C Program.?

int main()

{

int k;

for(k=1; k <= 5; k++);

{

printf("%d ", k);

}

return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

80.

What is the output of C Program.?

int main()

{ int a=14;

while(a<20)

{ ++a;

if(a>=16 && a<=18)

{ continue; }

printf("%d ", a);

}

return 0;

}

a)

15 16 17 18 19

b)

15 18 19

c)

15 16 20

d)

15 19 20

81.

What is the output of C Program.?

int main()

{

int a=10, b, c;

b=a++;

c=++a;

printf("%d %d %d", a, b, c);

return 0;

}

a)

10 11 12

b)

12 10 12

c)

12 11 12

d)

12 12 12

82.

Which of the following is an entry controlled statement?

a)

while

b)

do while

c)

For

83.

Which of the following is an exit controlled loop?

a)

while

b)

do while

c)

for

84.

The while loop executes at least once.the statement is

a)

True

b)

False

85.

do while loop executes at least once.the statement is

a)

True

b)

False

86.

In the following loop construct, which one is executed only once always.

for(exp1; exp2; exp3)

a)

exp1

b)

exp2

c)

exp3

d)

All of these

87.

do-while loop terminates when conditional expression returns?

a)

One

b)

Zero

c)

Non zero

d)

None of these

88.

A ________________ executes the sequence of statements many times until the stated condition becomes false.

a)

data structures

b)

control structures

c)

loop

d)

OOPS

89.

The _____________ is used in many imperative programming languages notably C and C++.

a)

do loop

b)

for loop

c)

while loop

d)

do while loop

90.

A ____________ is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.

a)

while loop

b)

do loop

c)

for loop

d)

do while loop

91.

A ______________ is a control flow statement that executes a block of code at least once.

a)

do loop

b)

do while loop

c)

while loop

d)

for loop

92.

A _____________ is used to repeat a specific block of code a known number of times.

a)

do loop

b)

for loop

c)

do while loop

d)

while loop

93.

The ______________ can be thought of as a repeating if statement.

a)

do while loop

b)

do loop

c)

while loop

d)

for loop

94.

____________________ either repeatedly executes the block, or stops executing it, depending on a given boolean condition at the end of the block.

a)

for loop

b)

do loop

c)

do while loop

d)

while loop

95.

If we have declared an array described below -

int arr[6];

then which of the following array element is considered as last array element ?

a)

arr[6]

b)

arr[4]

c)

arr[0]

d)

arr[5]

96.

What is the length of the following array: int data[] = { 12, 34, 9, 0, -62, 88 };

a)

1

b)

5

c)

6

d)

12

97.

Assuming int is of 2 bytes, what is the size of int arr[15];?

a)

15

b)

19

c)

11

d)

30

98.

What is meaning of following

declaration ?

int arr[20];

a)

Array of size 20 that can have integer address

b)

Array of Size 20

c)

Integer Array of size 20

d)

None of these

99.

In general, the index of the first element in an array is __________

a)

0

b)

-1

c)

2

d)

1

100.

What is the output of C Program.?

int main()

{

int k;

for(k=1; k <= 5; k++);

{

printf("%d ", k);

}

return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

101.

What's wrong? for (int k = 2, k <=12, k++)

a)

the increment should always be ++k

b)

the variable must always be the letter i when using a for loop

c)

there should be a semicolon at the end of the statement

d)

the commas should be semicolons

102.

What output is produced by the following segment of code:


for (int dmc = 8; dmc >= 0; dmc-=4)

{

printf("%d",dmc);

}

a)

8 4 0

b)

8 4

c)

8

d)

No Output

e)

Infinite Loop

103.

What output is produced by the following segment of code:


for (int dmc = 8; dmc >= 8; dmc-=4)

{

printf("%d",dmc);

}

a)

8 4 0

b)

8 4

c)

8

d)

No Output

e)

Infinite Loop

104.

What output is produced by the following segment of code:


for (int dmc = 8; dmc >= 10; dmc-=4)

{

printf("%d",dmc);

}

a)

* * *

b)

* *

c)

*

d)

No Output

e)

Infinite Loop

105.

What output is produced by the following segment of code:

int x;

for (x = 10; x > 0; x++)

{

printf("%d",x)

}

a)

10 9 8 7 6 5 4 3 2 1

b)

10 9 8 7 6 5 4 3 2 1 0

c)

9 8 7 6 5 4 3 2 1

d)

No Output

e)

Infinite Loop

106.

What output is produced by the following segment of code:


for (int x = 5; x > 0; x--)

{

printf("* ");

}

a)

* * * * *

b)

* * * * * *

c)

*

d)

No Output

e)

Infinite Loop

107.

The following loop displays _______________.

for (int i = 1; i <= 10; i++) {

printf("%d",i);

i++;

}

a)

1 2 3 4 5 6 7 8 9

b)

1 2 3 4 5 6 7 8 9 10

c)

1 2 3 4 5

d)

1 3 5 7 9

108.

What is the output for y?

int y = 0;

int i;

for (i = 0; i<10; ++i) {

y += i;

}

printf("%d",y);

a)

1

b)

36

c)

45

d)

9

109.

What is the number of iterations in the following loop:

for (i = 1; i < n; i++) {

// iteration

}

a)

2*n

b)

n

c)

n - 1

d)

n + 1