From a6a578f585edad26c9f114c31c210c2327888c46 Mon Sep 17 00:00:00 2001 From: sruti2024 Date: Wed, 15 Jan 2020 11:34:13 +0530 Subject: [PATCH] adding c++ program to generate kaprekar number --- kaprekar_number.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 kaprekar_number.cpp diff --git a/kaprekar_number.cpp b/kaprekar_number.cpp new file mode 100644 index 0000000..eddffc8 --- /dev/null +++ b/kaprekar_number.cpp @@ -0,0 +1,37 @@ +#include +#include +using namespace std; +int sum(int n) + { + int m=n,d=0; + int s=m*m; + //while loop begins to count the number of digits + while(n!=0) + { + d++; + n=n/10; + } + int a=s%(int)pow(10,d); + int b=s/(int)pow(10,d); + int su=a+b; + return(su); + } + int main() + { + int k=0,num,m; + cout<<"Enter the upper and lower limits :"<>num>>m; + //displaying the reasult + cout<<"The kaprekar numbers within "<