Monday 16 June 2014

C++ program to calculate generic root of any number



Here is a C++ program to calculate generic root of any number


 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;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment