Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int a, s;
  5.     printf("Enter value of a: ");
  6.     scanf("%d",&a);
  7.     s = 0;
  8.     while(a > 0)
  9.     {
  10.         s = s + (a%10);
  11.         a = a / 10;
  12.     }
  13.     printf("Sum of digits: %d",s);
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement