C program to find the sum of digits of numbers until the resulting value is single digit number



#include<stdio.h>

#include<conio.h>

main()

{

    int n,t,sum;

    int r;

    printf("Enter the numbers: ");

    scanf("%d",&n);

    t=n;

    while(t>9)

    {
    sum=0;
    
    do
    {
    
    r=t%10;

        sum=sum+r;

        t=t/10;

        }
        while(t!=0);

        t=sum;
    }

    printf("Final result is=%d",t);

    }


Comments