wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

IEEE_Round2

Total questions: 13

Worksheet time: 19mins

Name
Class
Date
1.

Type your email address

4 lines
2.

If M is multiple of 3 and 5 then print "Good Number" (without quotes).; If M is only multiple of 3 and not of 5 then print "Bad Number" ; If M is only multiple of 5 and not of 3 then print "Poor Number"; If M doesn't satisfy any of the above conditions then print "-1"

What's the error in the following code

a)

O!=0 condition is missing

b)

n!=0 condition is incomplete

c)

n==0 should't include O==0 condition

d)

None of the above

3.

We need to find the middle element of the linked list.

But the code we wrote won't compile. What should we change

a)

change the function return value type to Node because the function will return Node

b)

change the p2->next condition as it won't represent a boolean(there is a 0 instead of false)

c)

change the function return value type to void because the function won't return anything

d)

change the p2->next and p1->next condition as it won't represent a boolean(there is a 0 instead of Null)

4.

What's the output

a)

Constructing object number 1

Constructing object number 2

Constructing object number 3

Constructing object number 4

Destructing object number 1

Destructing object number 2

Destructing object number 3

Destructing object number 4

Caught 4

b)

Constructing object number 1

Constructing object number 2

Constructing object number 3

Constructing object number 4

Destructing object number 3

Destructing object number 2

Destructing object number 1

Caught 4

c)

Constructing object number 1

Constructing object number 2

Constructing object number 3

Constructing object number 4

Destructing object number 4

Destructing object number 3

Destructing object number 2

Destructing object number 1

Caught 4

d)

Constructing object number 1

Constructing object number 2

Constructing object number 3

Constructing object number 4

Destructing object number 1

Destructing object number 2

Destructing object number 3

Caught 4

5.

We need to add integers to an array such that if

input=[1,2,0,0],i=5,3 output=[1,2,5,3]

a)
b)
c)
d)

None of the above are correct

6.

We need to add a node in front of linked list.Now which code has the correct implementation

a)

void push(Node** head, int data)

{

Node* new_node = new Node();

new_node->data =data;

new_node->next = (*head_ref);

(*head_ref) = new_node;

}

b)

void push(Node** head_ref, int data)

{

Node* new_node = int Node


new_node = data;

new_node = (*head_ref);

(*head_ref) = new_node;

}

c)

int push(Node** head_ref, int data)

{

Node* new_node = int Node


new_node = data;

new_node = (*head_ref);

(*head_ref) = new_node;

}

d)

Node push(new Node head_ref, int data)

{

Node* new_node = int Node


new_node = data;

new_node = (*head_ref);

return new_node;

}

7.

We need to find the number of true in an array.

For example in an array[true,true,false,false,true] output will be 3.

So the function will be

a)
b)
c)
d)

None of the above are correct

8.

Which is the best approach to reverse the stack according to the time complexity?

a)

Stack reversal using another stack

b)

Reversing of the stack using recursion

c)

By using a map to store all the stack elements and then reversing it

d)

Reversing a stack without using extra space and reccursion

9.

int main()

{

int x = -1;

char *ptr;

ptr = new char[256];

try {

if( x < 0 )

{

throw x;

}

if(ptr)

{

throw " ptr is NULL ";

}

}

catch (...)

{

cout << "Exception occurred: exiting "<< endl;

exit(0);

}

getchar();

return 0;

}

What will be the output?

a)

Compilation error

b)

Exception occurred: exiting

c)

ptr is Null

d)

ptr is NULL

Exception occurred: exiting

10.

let re = new RegExp('ab+c');

Which of the following will be a match?

(hint '+' = more than 1 char)

a)

abbba+hbbdcac

b)

abacbbacabc

c)

acpgbbaABCn

d)

ABBBABAABBC

11.

This code does not execute properly. Try to figure out why

multiply(int a, int b)

{

a * b;

}

a)

There is no return statement here

b)

it has not defined any return type

c)

its multiplying the numbers wrong

d)

There is a program error in this program

12.

We need to reverse an integer. But only 1 of the following code gives us the correct output.

a)
b)
c)
d)

None can solve the problem

13.

int main()

{

unsigned char a = 5, b = 9;

printf(" %d, %d\n", a, b);

printf(" %d\n", a & b);

}

return 0;}

What will be the output of the program(hint: it is using bitwise operators)

a)

a=5,b=9,a&b=1

b)

5,9,1

c)

5,9

1

d)

5,9,0