Check if number is a power of 2

How will you check if a number if a power of two or not? For example: 4, 8, 1024 etc are powers of two. But […]

value of i++ + ++i or ++i + i ++

If the initial value of i is 2 What is the value of expression i++ + i++?

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.

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 […]

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 […]

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 […]

Pass by Reference v/s Pass by value

In C language, everything is pass-by-value and C++ supports that. But C++ also provides provision to pass arguments by reference (by declaring new reference data […]

Compute Max and Min without branching

Given 2 unsigned integers, write expressions to find the maximum and minimum of these 2 integers without using either if-else or conditional operator.