English, asked by JEET93941, 9 months ago

Write a program to find the repeated sum of digits of a number until it becomes a single-digit number in c++

Answers

Answered by sakshijalan82191
2

Answer:

sorry I know only Java..... ..........

Answered by rohanbhairav123
14

Answer:

#include<iostream>

using namespace std;

int p(int n)

{

 int sum=0;

 while(n>0||sum>9)

 {

   if(n==0){

     n=sum;

     sum=0;

   }

   sum=sum+n%10;

   n=n/10;

 }

 return sum;

}

int main()

{

 int n;

 cin>>n;

 cout<<p(n);

}

Explanation:

Similar questions