Write a C program to find the sum of digits of given numbers

#include<stdio.h>
main()
{


    int n,sum=0;
    printf("Enter a number:");
    scanf("%d",&n);
    while(n!=0){
        sum += n%10;
        n=n/10;
    }
    printf("The sum is %d\n",sum);
}

Post a Comment

0 Comments