Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write a C program to find whether a given number is a Kaprekar number or not

+4 votes
asked Oct 29, 2022 by Tanveer Singh (260 points)

Consider an n-digit number k. Square it and add the right n digits to the left n or n-1 digits. If the
resultant sum is k, then k is called a Kaprekar number. For example, 9 is a Kaprekar number
since 92 = 81 & 8+1=9
and 297 is a Kaprekar number since 2972 = 88209 & 88+209 = 297.
Write a C program to find whether a given number is a Kaprekar number or not.
Input Format:
Input consists of a single integer.
Output Format:
Refer sample output for details.
Sample Input 1: 9
Sample Output 1:

Kaprekar Number
Sample Input 2: 101
Sample Output 2:
Not A Kaprekar Number

1 Answer

0 votes
answered Oct 30, 2022 by Peter Minarik (86,200 points)

Please, share your solution and ask specific questions and people will be more than happy to help you fix or optimize your code.

Please, do not ask others to solve your school assignment for you.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...