Question: 2 . Raptor Project: A Raptor code for Kaprekar's constant [ 2 0 marks ] Kaprekar's Constant ( { } ^ { 1 }

2. Raptor Project: A Raptor code for Kaprekar's constant [20 marks]
Kaprekar's Constant \({}^{1}\) is 6174. It seems a simple random number, but it has a very special property. First choose a four-digit number where the digits are not all the same (that is not 1111,2222, etc.). Then rearrange the digits to get the largest and smallest numbers these digits can make. Finally, subtract the smallest number from the largest to get a new number, and carry on repeating the operation for each new number. The operations, always end up with the number 6174.
Create a Raptor program that prompts the user to enter a proper four-digit number. Break down the number into its individual digits and store these digits in an array. Sort the digits in either ascending or descending order. Use the sorted digits to form the largest and smallest possible numbers. Subtract the smaller number from the larger one. Repeat this process until the result is 6174.
[Hint: Do a sample calculation, manually. This helps to build the flow-chart or algorithm along the way. Also, for sorting the digits of the input number, use Bubble algorithm.]
2 . Raptor Project: A Raptor code for Kaprekar's

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!