
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Find last five digits of a given five digit number raised to power five in C++
In this problem, we are given a number N. Our task is to find the last five digits of a given five digit number raised to power five.
Let’s take an example to understand the problem,
Input: N = 25211
Output:
Solution Approach
To solve the problem, we need to find only the last five digits of the resultant value. So, we will find the last digit of the number after every power increment by finding the 5 digit remainder of the number. At last return the last 5 digits after power of 5.
Program to illustrate the working of our solution,
Example
#include <iostream> using namespace std; int lastFiveDigits(int n) { int result = 1; for (int i = 0; i < 5; i++) { result *= n; result %= 100000; } cout<<"The last five digits of "<<n<<" raised to the power 5 are "<<result; } int main() { int n = 12345; lastFiveDigits(n); return 0; }
Output
The last five digits of 12345 raised to the power 5 are 65625
- Related Articles
- C program to find sum of digits of a five digit number
- The difference between the greatest five-digit number and the greatest five-digit number with all different digits is:(a) 1000 (b) 12345(c) 1 (d) 1234
- Find the greatest five-digit number, which is a perfect square.
- (a) State five characteristics of metals and five characteristics of nonmetals.(b) State five uses of metals and five uses of non-metals.
- State five uses of metals and five of non-metals.
- Find five rational number between 1 and 2
- Find any five rational number less than 1.
- Name five things made up of five different kinds of elements
- A number consists of two digits whose sum is five. When the digits are reversed, the number becomes greater by nine. Find the number.
- Five times a number x increased by seven
- How to limit records to only the last five results in MySQL
- Number of digits in 2 raised to power n in C++
- State any five physical properties of metals and five physical properties of non-metals.
- Five Unexpected Uses of Canva
- Five Levels of Organisational Conflict

Advertisements