- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this problem, we are given two numbers A and B. Our task is to create a program to calculate the *Fast average of two numbers without division. *

**Input: **A = 34 B = 54

**Output: **44

**Solution Approach: **

Normally, the average is calculated by adding two numbers and then divide it by 2. This requires division but we need to find the average without using division. This can be done using right shift operator >> and shift the binary expansion instead of using division operator.

#include <iostream> #include <stdio.h> using namespace std; int calcAvgWODiv(int A, int B) { int average = (A + B) >> 1; return average; } int main() { int A = 123 , B = 653; cout<<"The average of the number is "<<calcAvgWODiv(A, B); return 0; }

The average of the number is 388

- Related Questions & Answers
- Addition of two numbers without propagating Carry?
- Average of a stream of numbers in C++
- Division without using ‘/’ operator in C++ Program
- C Program to find sum of two numbers without using any operator
- Average of Squares of Natural Numbers?
- Splitting array of numbers into two arrays with same average in JavaScript
- Find the Sum of two Binary Numbers without using a method in C#?
- Find HCF of two numbers without using recursion or Euclidean algorithm in C++
- Average numbers in array in C Programming
- Average of max K numbers in a stream in C++
- C++ Program to Calculate Average of Numbers Using Arrays
- Finding LCM of more than two (or array) numbers without using GCD in C++
- Average of Squares of n Natural Numbers?
- How to swap two numbers without using a temp variable in C#
- 8085 program to sum of two 8 bit numbers without carry

Advertisements