C program to find the sum of individual digit of a given number

program to find the sum of individual digit of a given number:

Here I shared C program to reverse the given number using a while loop statement.
For example, if the user enters 5270 then the output will be:

 Enter the number:5270

 Sum of individual number digits of a number 5270 is 14



#include<stdio.h>
int main()
{
 int orig,save,a,sum=0;
  printf("\n Enter the number:");
  scanf("%d",&orig);
   save=orig;
    while(orig!=0)
   {
    a=orig%10;
    sum=sum+a;
    orig=orig/10;
   }
   printf("\n Sum of individual number digits of a number %d is %d",save,sum);
 return 0;
}

NOTE: You have any problem in above C Program do not hesitate and write your problem in the comment box. I will support your problem.

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form