Using sizeof to get size of an Array or pointer

sizeof operator returns size in bytes. For example, In an implementation where 2 bytes (16bits) of memory is allocated to an int type, the below code will […]

sizeof operator in C/Cpp language

sizeof is a unique operator in C/C++ language which returns the amount of memory (in bytes) allocated to its operand. For example, if an implementation stores […]

Output of C++ program

What will be the output of below C++ program?

Sum the digits of a number in single statement

Write a single statement (simple or compound) which can compute sum of digits of an unsigned int.

comma operator

Comma in C and C++ comes in two flavours As separator (used to separate parameters in a function call) As operator (rarely used) The two flavors are […]

Difference between malloc, calloc, free and realloc functions

Functions malloc, calloc, realloc and free are used to allocate /deallocate memory on heap in C/C++ language. These functions should be used with great caution […]

Big and Little Endian

Little and big endian are two ways of storing multibyte data ( int, float, etc) in memory. – If machine is big endian, then first […]

Add two integers without using arithmetic operator

Write a function that accepts two unsigned int and return sum of these two integers. The function should not use any arithmetic operator (mayuse bitwise […]

Order of evaluation of operands

What will be the output of the below code in C or C++ language? int x = 0; int a() { x = 10; return […]

Difference between struct and class in C++

In C++, a struct can have functions also, the way we have in a class. For example, the below definition of Node in C++ is perfectly valid. struct […]