Magical Number | Do/While Loop | Lecture #85 #numbersystem #hindi #coding #logical #developer
This program is written to check whether a given number is a magical number or not. First, the program asks the user to enter a number. The entered number is stored and also saved as the original number so it can be compared later. Next, the program finds the sum of all digits of the number. It separates each digit of the number and adds them together to get the total sum. After calculating the sum of the digits, the program stores this sum and then finds the reverse of that sum. The reverse is obtained by changing the order of the digits of the sum. Then the program multiplies the sum of the digits with its reversed number. Finally, the program compares this multiplication result with the original number entered by the user. If the multiplication result is equal to the original number, the program prints that the number is a magical number. If the result is not equal, the program prints that the number is not a magical number. For example, if the number is 1458, the sum of its digits is 18. The reverse of 18 is 81. When 18 is multiplied by 81, the result is 1458, which is the original number. Therefore, 1458 is a magical number. #cprogramming #code #coding #logical #numbersystem #beginners #developer #compilation #logicalreasoning
Download
0 formatsNo download links available.