# cpp

### Divide and Multiply a number by Two using Bitwise Operator (Without...

Why use left-shift and right-shift operators instead of generic divide(/) and multiply(*) operators? Explanation: The '/' and '*' operators can be very time-consuming...

### C++ Program to Find the nth Bit of Number (Bit Masking)

Sometimes interviewers also twist the question and ask you to check if the nth bit is set or not. You have to follow the same approach. Algorithm and approach: Left shift 1...

### C++ Program to Check Odd or Even Number without using Modulo

We all know about the odd and even numbers. In simple terms, if the number is divisible by two, it is even. If the number is not divisible by two, it is...

### Write a Program to Find the Median of Array (by Sorting)

Explanation You will be given a list of numbers. Let's say 7, 8, 4, 5, 2 First, you have to sort the numbers using the swapping methodology. Sorted list: 2, 4, 5, 7,...

### Write a Program to Find the Transpose of a Matrix

Explanation Transposing a matrix is also known as flipping a matrix where rows become columns and columns become rows, In other words, lets M is a matrix and Transpose of...

### Second Largest/Smallest Number in Array in C/C++, Java and Python

In an earlier tutorial, we have seen how to find the smallest or largest number from the integer array. In this tutorial, we are going to find the second smallest number in an...

### Find the Smallest and Largest Number in Array in C/C++, Java and Python

Here is the program to find the smallest and largest number in the array in C/C++, Java and Python. I have also added the comment explaining each line of the code. So the code...

### What is Array | Print Elements in Array (Traversing)

What is an array? Array is a collection of multiple elements. It is one of the derived data types in C programming. Characteristics of array: Elements (aka items) in the...

### Program to Check and Print All Perfect Numbers in the Given Range

This is one of the popular number questions asked in interviews. There are many students who are interested to become software developers so the best way to crack the SDE...