Вы находитесь на странице: 1из 3

1. Raymond bought a car for $40, 000.

He took a $20,000 loan from a bank at an interest rate of 15% per


year for a 3-year period. What is the total amount (interest and loan) that he would have to pay the bank at
the end of 3 years?
Solution:
Simple Interest = 20,000 × 15% × 3 = 9,000
At the end of 3 years, he would have to pay
$20,000 + $9,000 = $29,000
2. You have been allocated a class A network address of 29.0.0.0. You need to create at least 20
networks and each network will support a maximum of 160 hosts. Would the following two subnet
masks Work? 255.255.0.0 and or 255.255.255.0

Solution:
Here we have to subnet a class A network address considering the following two conditions:
(i) to create at least 20 networks
(ii) maximum 160 hosts per network
--> Mask 255.255.0.0 has 8 bits for the subnet and 16 bits for the host
8 bits would accommodate 2^8=256 subnets [satisfy condition (i)]
16 bits would accommodate 2^16 -2 = 65534 hosts [does not satisfy condition (ii) since it is over
160]
--> Mask 255.255.255.0 has 16 bits for the subnet and 8 bits of the host.
16 bits would accommodate 2^16 = 65536 subnets [satisfy condition (i)]
8 bits would accommodate 2^8 -2 = 254 hosts [does not satisfy condition (ii) since it is over 160]
So according to the above explanation none of the subnet mask would work.
NB: Though the answer is mentioned as Both would work in several source. In the question if
minimum of 160 hosts is mentioned instead of maximum, then both would work.

3. What will be output of following c code?

#include<stdio.h>

int main(){

static int i;

for(++i;++i;++i) {

printf("%d ",i);

if(i==4) break;

return 0;

Answer: 2 4
4. What will be output of following c code?

#include <stdio.h>

int main()

int *p1,**p2;

double *q1,**q2;

printf("%d %d ",sizeof(p1),sizeof(p2));

printf("%d %d",sizeof(q1),sizeof(q2));

getch();

return 0;

Answer:

4 4 4 4 for 32-bit machine


Explanation: The size of the pointer basically depends on the architecture of the system in which it
is implemented. For example the size of a pointer in 32 bit is 4 bytes (32 bit ) and 8 bytes(64 bit ) in a
64 bit machines. The bit types in a machine are nothing but memory address, that it can have.

5. What will be output if you will execute following c code?

#include<stdio.h>
int main()
{
char arr[20]="MysticRiver";
printf("%d",sizeof(arr));
return 0;
}

Answer:
20
6. Y= A’ B’C’D’+A’B’CD’+A’BCD’+A’BCD+AB’C’D’+AB’CD’+ABCD’+ABCD
simplify the expression using K-MAP

Answer: BC+B'D'/B'D'+BC

7. What is the best case time complexity of recursive bubble sort? Write the algorithm of Merge sort.
Only Algorithm part not total part

Answer: Best case time complexity of recursive bubble sort is 0(n).


Algorithm of Merge sort:
void merge_sort(int arr[], int left, int right)
{
if (left > right)
{
int mid = (right-left)/2;
merge_sort(arr,left, mid);
merge_sort(arr,mid+1, right);
merge(arr,left, mid, right); //function to merge sorted arrays
}
}
8. 38, 27, 43, 3, 9, 82, 10 Sorting these number using Merge Sort
Answer:

9. How to find Third highest salary in Employee table using self-join?


SQL:
Select * from Employee a Where 3 = (Select Count (distinct Salary) from Employee where
a.salary<=b.salary;

10. Write an SQL query to print details of the Workers who have joined in Feb’2014.
SQL:

Select * from Worker where year(JOINING_DATE) = 2014 and month(JOINING_DATE) = 2;

Вам также может понравиться