Swapping two variables without using third variable

This is a very common interview question, esp. at the junior level. Let us first write a function that swap two integers using a third […]

Generic pointers in C language

Generic programming, loosely means that the code we have written is type-independent. It is a larger topic, macros in C language also comes under generic programming. […]

Find minimum of 3 numbers without using comparator operator

How will you find minimum of three integers without using any comparison operator ?

Function to swap strings in C

Write a C language function that will swap two strings.

Which of the two comparison is better

While comparing a variable with a constant (literal) in C/C++ language, which of the two ways of comparison should we use ? if( x == […]

Find size of a struct without using sizeof operator

How will you find the size of a structure in C/C++ language without using sizeof operator. (Note: sum of sizes of all fields of a […]

What is fork. How are processes created using fork

A process executes the below code: fork(); fork(); fork(); How many child processes will be created ?  What is the meaning of fork command ?           

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

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.