filmov
tv
Adam Number| While Loop | Lecture #70 #cprogramming #coding #c #hindi

Показать описание
📚 This C program checks whether a given number is an Adam number or not 🔍. An Adam number is a number that satisfies a specific condition 🔢. What is an Adam Number? 🤔 An Adam number is a number that, when squared 📈, reversed 🔄, and then the reversed number is squared again 📈 and reversed 🔄, results in the same number as the original number squared 📈. Confused? Let's break it down 🔨! Step-by-Step Process 🔀 User Input 📝: The program asks the user to enter a number 🤔. Square the Original Number 📈: The program calculates the square of the input number 🔢. Reverse the Original Number 🔄: The program reverses the digits of the original number 🔄. Square the Reversed Number 📈: The program calculates the square of the reversed number 🔢. Reverse the Squared Reversed Number 🔄: The program reverses the digits of the squared reversed number 🔄. Check for Adam Number 🤔: The program checks if the reversed squared reversed number is equal to the original squared number 📊. If they are equal, the number is an Adam number 🎉! How the Program Works 🔧 The program uses variables to store the input number, its square, the reversed number, and the reversed squared reversed number 📝. It uses while loops to reverse the numbers 🔄 and checks the condition for an Adam number 🤔. Issues in the Program 🚨 The program has a small mistake 🙅♂️. The condition in the second while loop should be sq2 != 0 instead of sq21 != 0. Also, the return type of main should be int, not void 🙅♂️. Example Use Case 📊 Let's take the number 12 as an example 🤔. Square of 12: 144 Reverse of 12: 21 Square of 21: 441 Reverse of 441: 144 Since 144 (reversed squared reversed) equals 144 (original squared), 12 is an Adam number 🎉!