Lucky number

an anonymous user · June 24, 2022
#include <stdio.h>

int main() {
    int n,k,m,x,sum,x1,sum1;
    scanf("%d\n",&n);
    while(n>0)
    {
        m=n%10;
        k=k+m;
        n=n/10;
    }
    while (k>0)
    {
        x=k%10;
        sum=sum+x;
        k=k/10;
    }
    if (sum>=10)
    {
        x1=sum%10;
        sum1=sum1+x1;
        sum=sum/10;
    }
    if (sum<10)
    {
        sum1=sum;
    }
    printf("Your Lucky number is %d",sum1);
}
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.