In this chapter we shall learn about below topics: #define directive Undefined a Macro Token pasting and stringizing Operators #include directive Conditional Compilation #ifndef Directive #error Directive #pragma Directive Assertions in C Predefined macros in C 1. #define directive The #define is a pre-processor …
Storage classes are used to know the scope and lifetime of a variable. There are 2 types of storage classes. Local Global Below are different storage class specifiers: auto register static extern Before looking into storage classes, we shall discuss about variables and how …
You are given a number range, you need to find the bitwise and of all the numbers in the range. Example: The bitwise and of 5, 6, 7 will be 4. The solution is very simple, once you understand the concept below: …
You are given 2 integers, and you need to return the count at which the bits are different in their binary form. Consider 8 and 1 As highlighted in the image, there are 2 positions where the bits are different. Hence output should be …
You are given a number; you need to create an array to fill the number of 1’s present in their binary format. Example: Input n = 3 Output = Because for 0, the number of set bits is 0. For 1, it’s binary …
Problem statement: You are given an array of numbers from 1 to n, in any order, one number will be missing. You need to find a missing number. Example: Input: Output: 2 We can solve this problem by 2 methods: Finding the …
Given a number, you need to check if the number is a power of 2, return true or false accordingly. Example: Input: 1 Output: True Because 2^0 is 1 Input: 15 Output: False Because 15 is not a power of 2. …
Problem statement: You are given a number, return the number of set bits if that number, when represented that number in binary format. Example: If the input number is 10, it’s binary representation is 1010. The number of set bits are 2. This problem …
In this tutorial we shall see how to print all the nodes that is k distance from root. Problem statement: Given the root node and the distance k, print all the nodes that are at distance k from root node. Consider the image below: …