This C++ Program demonstrates the implementation of Russian Peasant Multiplication.
Here is source code of the C++ Program to demonstrate the implementation of Russian Peasant Multiplication. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
* C++ Program to Implement Russian Peasant Multiplication
using namespace std;
* multiply two numbers using Russian Peasant method
unsigned int russianPeasant(unsigned int a, unsigned int b)
int res = 0;
while (b > 0)
if (b & 1)
res = res + a;
a = a << 1;
b = b >> 1;
cout << russianPeasant(15, 5) << endl;
cout << russianPeasant(13, 6) << endl;
$ g++ russian_peasant.cpp $ a.out 75 78 ------------------ (program exited with code: 1) Press return to continue
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
If you wish to look at all C++ Programming examples, go to C++ Programs.
- Get Free Certificate of Merit in C++ Programming
- Participate in C++ Programming Certification Contest
- Become a Top Ranker in C++ Programming
- Take C++ Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy C++ Books
- Practice Programming MCQs
- Buy Computer Science Books
- Apply for Information Technology Internship
- Apply for Computer Science Internship