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

syntax of main in C/C++ language

In C/C++ language, main function comes in different flavors as shown below: int main(); int main(int argc, char **argv); int main(int argc, char **argv, char […]

Error in C language code

The function myfunc below is suppposed to print the size of array passed to it as parameter(arr). What do you think is the problem (if […]

Memory leaks and dangling pointers

Those who use languages like C and C++ that support user defined pointer variables, put utmost emphasis on implementing the pointers correctly. And rightfully so, […]

Find larger of 2 elements without branching

Given two unsigned integers, find the larger (or smaller) of the two without using branching (if-else or conditional operator).

One Definition Rule (ODR) in C++

One Definition Rule (ODR) In C++, declaration does not allocate any memory. Its only when an object (or function) is defined that an instance of […]