Automorphic Number | Do/While Loop | Lecture #88 #numbersystem #hindi #coding #logical #developer
🎯 Topic: Automorphic Number (Using Do-While Logic) This program is designed to check whether a given number is an automorphic number or not. 📌 What is an Automorphic Number? An automorphic number is a number whose square ends with the same number itself. 👉 Example: 5 → Square = 25 → ends with 5 ✅ 6 → Square = 36 → ends with 6 ✅ 25 → Square = 625 → ends with 25 ✅ ⚙️ Step-by-Step Explanation of the Program User Input The program first asks the user to enter a number. This number is stored in a variable. Square Calculation The program calculates the square of the entered number. For example, if the user enters 25, then square becomes 625. Extracting Last Digits Now the program extracts the last two digits from the square. It does this using a modulus operation (remainder). Example: Square = 625 Last two digits = 25 Do-While Loop Usage A do-while loop is used here, but it runs only once because of a break statement. So practically, the loop is just used to execute the extraction once. Comparison The program compares: Original number Extracted last digits of the square If both are equal → it's an automorphic number Otherwise → it's not 🧠 Important Observation This program only checks for numbers with 2 digits correctly because it extracts only the last two digits. If you enter a number with more digits (like 376), the logic may not work properly because it still checks only the last 2 digits. ✅ Final Output If the number matches the ending digits of its square → 👉 “This is an automorphic number” Otherwise → 👉 “This is not an automorphic number”
Download
0 formatsNo download links available.