Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

25.3K

## Total Set :5

##### Question: 1 / 10

Briefly introduce your self, and current project you are working.

##### Question: 2 / 10

How to check a number, whether it is power of 2 or not.

#include

int main()
{
int x;
scanf("%d",&x);
if((x)&&!(x&(x-1)))
{
printf(" %d is power of 2\n",x);
}
else
{
printf(" %d not power of 2 \n",x);
}
}

##### Question: 3 / 10

How to delete a node in linklist, when one address of that node is given.

{
if (*pos == NULL) // If linked list is empty
return;

else {
struct Node* temp = pos->next;

// Copy data of the next node to current node
pos->data = pos->next->data;

// Perform conventional deletion
pos->next = pos->next->next;

free(temp);
}
return 0;
}

##### Question: 4 / 10

How to find the nth node in linklist from back.

Use 2 pointers:-

pNthNode
pTemp

Both the nodes point to the HEAD of the list. pNthNode starts moving only after pTemp has moved n nodes forward. From there, both nodes move forward until pTemp reaches NULL.
pNthNode now points at the nth node from the end.

/*
Defining a function to find the nth node from the end.
*/
struct node * nthNodeFromEnd(struct node * head, int n)
{
// we need to find the nth node from the end.
struct node * pTemp = head;
struct node * pNthNode = head;

int nCurrentElement = 0;

int counter = 0;

while(counter != n)
{
pTemp = pTemp -> next;
counter++;
}

while(pTemp != NULL)
{
pNthNode = pNthNode -> next;
pTemp = pTemp -> next;
}

return pNthNode;
}

##### Question: 5 / 10

What is volatile.

Things which are all changeable is volatile.

for example, int a=5;

a=a+1; //value changes,this is volatile.

by default all variables are volatile.

##### Question: 6 / 10

What is mutex and semaphore, what is difference in both, is binary

##### Question: 7 / 10

what is virtual memory.

##### Question: 8 / 10

Some questions from paging, what is it, how to get address.

##### Question: 9 / 10

How to implement sizeof operator.

 `#define my_sizeof(type) (char *)(&type+1)-(char*)(&type)``int` `main()``{``    ``double` `x;``    ``printf``(``"%d"``, my_sizeof(x));``    ``getchar``();``    ``return` `0;``}` 