generic root means:
in this we do addition of a given number until reached a single digit after addition . For example:
Generic root of 784: 7 + 8 + 4 = 19 since 19 is a two digit numbers so 1 + 9 = 10.then again add 1 +0=1
So, generic root of 784 = 1
#include<stdio.h>
int main(){
long int num, sum, r;
printf("\n Enter a number:-");
scanf("%d",&num);
while(num>10){
sum=0;
while(num)
{
r=num%10; //we are taking modulus of the number
num=num/10; //now dividing number by 10
sum=sum+r; //take variable sum and store the value of r
}
if(sum>10)
num=sum;
else
break;
}
printf("\n Sum of the digits in single digit is: %d",sum);
return 0;
}
Sample output:
Enter any number: 245
Generic root: 2
0 Comment(s)