# SP Contest 2

1
 Question 1
In an experiment, one red dice and one black dice(both are fair) are rolled. What is the probability that,
1. The number on black dice will divide the number on red dice.
2. Number on black dice is multiple of the number on red dice.
 A 22 / 36 and 14 / 36 respectively B 12 / 36 and 18 / 36 respectively C 14 / 36 and 14 /36 respectively D 6 / 36 and 8 / 36 respectively
SP Contest 2
Discuss it

Question 1 Explanation:
We have two dice one is black and the other one is red: There will be a total of 36 outcomes.
1. We have to find the probability of the outcome that the number on black dice divides the number on red dice.
• 1 divides 1, 2, 3, 4, 5, 6.
• 2 divides 2, 4, 6.
• 3 divides 3, 6.
• 4 divides 4.
• 5 divides 5.
• 6 divides 6.
There are 14 number which will be counted as favorable outcomes. Therefor, probability = favorable outcome / total outcome. i.e. = 14 / 36.
2. We have to find the probability that the number on black dice is multiple of number on red dice.
• 1 is multiple of 1
• 2 is multiple of 1 and 2.
• 3 is multiple of 1 and 3.
• 4 is multiple of 1, 2 and 4
• 5 is multiple of 1 and 5.
• 6 is multiple of 1, 2, 3 and 6.
There are 14 number which will be counted in favourable outcome; probability = favorable outcome / total outcome. i.e. = 14 / 36.
 Question 2
What will be the remainder when 7100 is divided by 5?
 A 0 B 1 C 2 D 3
SP Contest 2
Discuss it

Question 2 Explanation:
This is a basic question of Chinese remainder theorem(CRT): We can write 7100 as (74)25. Now, 74 = 2401 when we divide it by 5 then 1 will be the remainder. Now, 7100 as (74)25 = (2401)25 mod 5 = 125 mod 5 = 1. Therefore, (7100 % 5) = 1.
 Question 3
What will be the output of the below C program:
```int calc(int i)
{

while(++i > 10); // statement 0

i++;

return i;
}

int main() {
int i = 2;

printf("%d", calc(i));

return 0;
}
```
Also, if we replace pre-increment operator by post-increment operator in statement 0, then what will be the output of the new program?
 A 11 and 12 B 12 and 11 C 4 and 5 D 4 and 4
SP Contest 2
Discuss it

 Question 4
Which of the following statement is used to copy data from one table and insert into another ?
 A SELECT AND INSERT INTO B INSERT INTO AND SELECT C SELECT FROM AND INSERT INTO D INSERT INTO SELECT
SP Contest 2
Discuss it

Question 4 Explanation:
The INSERT INTO SELECT statement copies data from one table and inserts it into another table. Example query : INSERT INTO table1 SELECT * FROM table2 WHERE condition;
 Question 5
Select the statements that are true about default and copy constructors in C++:
1. Compiler doesn’t create a default constructor if the user writes any constructor except the copy constructor.
2. Compiler creates a copy constructor if the user doesn't write its own copy constructor.
3. Compiler doesn’t create a default constructor if the user writes any constructor even if it is copy constructor.
 A 1 and 2 B Only 3 C Only 2 D 2 and 3
SP Contest 2
Discuss it

Question 5 Explanation:
 Question 6
Consider the following page reference string:
```4, 3, 2, 1, 2, 1,  5, 6, 1,  2,  7, 6, 3, 1, 4, 2
```
Which of the following options, gives the correct number of page faults related to LRU page replacement algorithms with 04 page frame and if there is an increment in page frame i.e. 05 page frame then what will be the correct number of page faults, assuming all frames are initially empty?
 A 10 and 10 B 11 and 10 C 10 and 11 D 11 and 11
SP Contest 2
Discuss it

Question 6 Explanation:
Least recently used (LRU) page replacement algorithm with 4 page frames: Total number of page faults = 11 Least recently used (LRU) page replacement algorithm with 5 page frames: Total number of page faults = 10 Therefore, option (B) is correct.
 Question 7
What is the probability of getting a Saturday in a Week?
 A 1 B 1/7 C 1/2 D 2/7 E 0
SP Contest 2
Discuss it

Question 7 Explanation:
Total number of Saturdays in a week = 1. The possible number of Saturdays in a week = 1. Therefore, the probability of getting a Saturday in a week = (1/1) = 1.
 Question 8
A C++ class can contain a member of SELF type if the member is.
1. Static
2. Pointer
3. Non-static
 A Only 3 B Both 2 and 3 C Both 1 and 2 D Only 1
SP Contest 2
Discuss it

Question 8 Explanation:
 Question 9
What will be the output of the below C++ program?
```#include<iostream>
using namespace std;

int main()
{
int a[] = {10,20,30,40,50};

cout<<(*(&a+1)-a);

return 0;
}
```
 A 10 B 0x7ffc7185f754 C 50 D 5
SP Contest 2
Discuss it

 Question 10
How does DHCP server dynamically assigns IP address to requesting host?
 A Dynamically, IP address is leased to requesting host for finite lease duration by DHCP server. B Dynamically IP address is leased to requesting host for an Infinite lease duration by DHCP server. C Dynamically, Static IP address is leased to requesting host for a finite lease duration by DHCP server. D Statically, dynamic IP address is leased to requesting host for an Infinite lease duration by DHCP server.
SP Contest 2
Discuss it

Question 10 Explanation:
There are 10 questions to complete.
1
My Personal Notes arrow_drop_up