SOURCE CODE OUTPUT
#include <iostream>
using namespace std;
int main()
{
int num,genric,temp=0;
cout<<"Enter the number ";
cin>>num;
while(num>9)
{
while(num!=0)
{
temp+=num%10;
num/=10;
}
num=temp;
temp=0;
}
cout<<"Generic root = "<<num;
}
using namespace std;
int main()
{
int num,genric,temp=0;
cout<<"Enter the number ";
cin>>num;
while(num>9)
{
while(num!=0)
{
temp+=num%10;
num/=10;
}
num=temp;
temp=0;
}
cout<<"Generic root = "<<num;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment