L1 Email Questions Sol
L1 Email Questions Sol
1. The following code contains an error. Change the code to fix the error.
#include <stdio.h>
void main()
{
int arr[5] = {10, 20, 30, 40, 50};
int *ptr1 = arr;
int *ptr2 = &ptr1;
printf("%d", **ptr2);
}
#include <stdio.h>
void main()
{
int arr[5] = {10, 20, 30, 40, 50};
int *ptr1 = arr; // The first value of array will be store in the *ptr1
int *ptr2 = ptr1; // the value on the address of ptr1 will be store in the address of ptr2
The output will be 10, if we use %x than this will convert in the hexadecimal number and give the output ‘a’
Answer:
The basic purpose for using XOR EAX, EAX is to set the EAX is 0 or we can say it will use to refresh the XOR. We can use
MOV EAX, 0; But XOR EAX, EAX is little bit faster than any other method.
CMP vs TEST
On x86, test uses to do a binary AND between the operands, just does not save the result anywhere. cmp subtracts the
second operand from the first without actually modifying the first operand.
For example, if we wanted to check if bit 6 (01000000b = 26 = 64) is set in register ch, then we use test ch, 64. If we
wanted to see if ch is less than/equal to/greater than 64, then we use cmp ch, 64.
As per the efficiency is concern I prefer to use TEST when testing for bits. The reason for this is that the processor
knows that this instruction doesn’t write its result and hence will not stall the pipeline in cases where using CMP (or AND,
or some instruction) would cause a pipeline stall.
4. What are the CALL & RET instructions and explain how they work?
Answer:
The CALL instruction interrupts the flow of a program by passing control to an internal or external subroutine. An
internal subroutine is part of the calling program while an external subroutine is some another program. The RETURN
(RET) instruction returns the control from a subroutine back to the calling program and optionally returns a value.
When calling an internal subroutine, CALL passes control to a label specified after the CALL keyword. When the
subroutine ends with the RETURN (RET) instruction, the instructions following CALL are processed.
When calling an external subroutine, CALL passes control to the program name that is specified after the CALL keyword.
When the external subroutine completes, we can use the RETURN (RET) instruction to return to where we left off in the
calling program. RET is used when program control is sent from a subroutine back to its parent routine.
Following operations are performed by the microprocessor when CALL is executed:
1. First Saves the contents of the program counter (the address of next instruction) on the stack.
2. Then Decrements the stack pointer register by two.
3. Then Jumps unconditionally to the memory location specified by the second and third bytes. The second byte
specifies a line number and third byte specifies a page number.
These call instruction accompanied by the RET instruction.
5. A container is running at the speed of 110 kilometers per hour. If the length of the container is 50 meters, how long
would it take to cross a bridge of 500 meters long?
Answer
Speed= 110 kmph = 110 * 5/18 mps = 275/9 mps
Total Distance covered by container= (500+50) mtr =550 mtr
Time taken by container to cross the bridge= Distance / Speed
“ “ “ “ “ “ = 550*9 /275 = 18 sec
6. The ratio of blue gems in gems packet is 3:7. What fraction of the gems in the packet is blue?
Answer:
Blue gems in packet = 3 *100/ (3+7) = 30
7. The minimum age required to become the prime minister of India is?
Answer:
For the PM of india one should be either the member of LS or RS, For the Loksabha Member he/she must be 25 years old
or for the RS member one should be 30 years old. So Minimum age required to become the PM of india is 25 years
8. What are the two states of India most richly endowed with iron ore?
Answer :
Bihar and Orrisa
9. Which is the MOST secure and LEAST secure of the following operating systems (OS):
- Windows
- Linux
- Android
- MAC
Answer :
Most Secure Operating System
Most Secure OS is Linux. Linux is an open source operating system whose code can be easily read out by the users, but
still, it is the more secure operating system when compared to the other OS(s). I am writing here some of the features of
Linux who make it more secure OS compare to other OS.
1. IPtables
A high tech security of IPtables is used by the Linux to enhance the security circle of the system.
2. Different working environment
Linux system operates in the different environment such as such as Linux Mint, Debian, Ubuntu, Gentoo, Mint , Arch,
and many others. The division and segmented working environment protect from the attack of the viruses.
3. Fewer users
The number of users in the Linux operating system is far less than the iOS or Windows user. Thus lesser people are using
Linux system makes it more secure as compared to the overly crowded operating system Windows.
Some of the other reason like a proper log is established in Linux of the timing and it can be viewed later on easily. Linux
also does not enable many default network services. Because every enabled network service, which is the area of
attacker can search the vulnerabilities and break into our system.
Least Secure Operating System:
Where the question of least security, It always changes on yearly basis. In these days, Mac OS is the least secure OS,
because of its vulnerability rate. In the year 2015, Apple OS found the least secure OS, In this OS attackers found the 387
vulnerabilities, which are the highest no. of vulnerabilities compare to any other OS.
10. Ashwini has reached the summit of Mount Everest, and is exhilarated albeit exhausted and famished. Describe
Ashwini’s experiences and emotions atop the mountain (in around 150 words).
Answer: Here, I can only guess what the Ashwini was thinking at that moment. He will have tired and his legs and body,
which were not giving up instead of getting severely tired and paining. He should be thankful to the god that he came in
that list in which only few peoples of the world are present. His water has been finished and he is feeling negligible
weight on his back. This small amount of water is nectar for him. After bit rest he is thinking to be descending from that
summit. His eyes are exhilarating and watching each and every part of Mt Everest. At this time he can’t compare his
feeling by anything else he achieved in this world. He is tired but happy, because his dream has been fulfilled.
Sometimes his eyes will come full of tears, these tears will not tears of sadness, these are the emotions which came out
in the form of tears and these emotions are screaming, YES , I have been achieved something in my life. If I will be in
place of ashwin really I think like that. But any expression and feelings can vary person to person.