Find generic root of a number

Find Generic Root of a Number

C program to find the generic root of a number

Today, we will learn to write a C program to find the generic root of a number. The program takes input from the user and finds the generic root of a number. So, let’s move to our Logic-

#include <stdio.h>
#include<conio.h>
void main()
{
    int num, sum, rem;
    printf("\n\t\t\t...Welcome To EduNews.Tech... ");

    printf("\n\nPlease Enter any number :  ");
    scanf("%d", &num);
    while(num >= 10)
    {
        for (sum=0; num > 0; num= num/10)
        {
            rem = num % 10;
            sum=sum + rem;
        }
        if(sum >= 10)
        {
            num = sum;
        }
        else
        {
            printf("Generic Root of Given number is :  %d", sum);
            break;
        }
    }
    printf("\n\n\n\t\t\tThankyou for Joining Us !");
    printf("\n\t\t\t!Regards EduNews !");

    getch();
}

Program Output:

generic root

I hope this post helps you to understand the “Generic root of a number” and its implementation in C programming language.

Keep coding 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *