In this tutorial, i am going to show you how to find the generic root of a number with the help of while loop and functions.

## All C Programs to Find Generic Root of a Number

- C Program to Find Generic Root of a Number
- C Program to Find Generic Root of a Number using Function

### C Program to Find Generic Root of a Number

/* C Program to Calculate Generic Root of a Number */ #include <stdio.h> int main() { int Number, Sum, Reminder; printf("\n Please Enter any number :- "); scanf("%d", &Number); while(Number >= 10) { for (Sum=0; Number > 0; Number= Number/10) { Reminder = Number % 10; Sum=Sum + Reminder; } if(Sum >= 10) { Number = Sum; } else { printf("\n The Generic Root of a Given Number = %d", Sum); return 0; } } }

**The result of the above c program; as follows:**

Please Enter any number :- 50

Generic Root of a Given Number = 5

### C Program to Find Generic Root of a Number using Function

/* C Program to Calculate Generic Root of a Number */ #include <stdio.h> int Sum_Of_Digits (int); int main() { int Number, Sum, Root; printf("\n Please Enter any number\n"); scanf("%d", &Number); while(Number >= 10) { Sum = Sum_Of_Digits (Number); if(Sum >= 10) { Number = Sum; } else { printf("\n Generic Root of a Given Number = %d", Sum); return 0; } } } int Sum_Of_Digits (int Number) { int Reminder, Sum; for (Sum=0; Number > 0; Number = Number/10) { Reminder = Number % 10; Sum = Sum + Reminder; } return Sum; }

**The result of the above c program; as follows: **

Please Enter any number :- 50 Generic Root of a Given Number = 5