#include <iostream>
int main()
{
int s,n,n1;
cout <<"enter the number \n";
s=0;
cin >>n;
cout <<"the given number is \n"<<n;
a: do
{
n1=n%10;
s=s+n1;
n=n/10;
}
while (n!=0);
if(s>9)
{
n=s;
s=0;
goto a;
}
else
cout <<"sum of digit is \n"<<s;
return 0;
}
int main()
{
int s,n,n1;
cout <<"enter the number \n";
s=0;
cin >>n;
cout <<"the given number is \n"<<n;
a: do
{
n1=n%10;
s=s+n1;
n=n/10;
}
while (n!=0);
if(s>9)
{
n=s;
s=0;
goto a;
}
else
cout <<"sum of digit is \n"<<s;
return 0;
}
No comments:
Post a Comment