Difference between return & exit(0)
What is the difference between exit(0) and return statement in the main function of a C++ program?
Check if number is a power of 4
Give a method to find whether an integer is a power of 4 or not.
Turn off the rightmost bit of an integer
How will you turn off the rightmost bit in the binary representation of an unsigned int number.
Traversing a matrix in spiral order
Given a Matrix, write a function that will print the elements in spiral order. For example, if the Matrix is as below: Then the output should be: 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10
volatile keyword in C / C++
What is the meaning of a volatile keyword in C & C++ language? How can the variables be modified from outside the scope of current program?
Number series questions
What will come next in the below number series: A) 4, 6, 12, 18, 30, 42, 60, 72, ? B) 22, 21, 23, 22, 24, 23, ?, ? C) 5, 6, 7, 8, 10, 11, 14, ?, ?
Delete a linked list
Write a function to delete a linked list. The function should take a pointer to the head of the list and should delete all the nodes in the linked list. Signature of the function should be like void deleteList(Node** head); This function is accepting Node ** and not Node* because it need to change the […]
Insert in a sorted linked list
Given a linked list, with all the nodes in sorted order. Write a function that inserts a new integer in the sorted manner. i.e If the list is as given below: 3 -> 6 -> 9 -> 10 -> 15 And if you want to insert 8 in this list, it should be inserted as […]
const keyword in CPP
What is the difference between the below two definition of pointers a and b: int x = 5; int* const a = &x; and int x = 5; const int * b = &x;
Recursive function to reverse a linked list
Earlier I talked about Reversing a Singly linked list without using recursion. Today let’s write a recursive function to reverse a singly linked list.