Q13. WAP to find sum of digits.
#include<stdio.h> #include<conio.h> void main() { int n, a, s=0; printf("Enter number: "); scanf("%d",&n); while(n<0) { a=n%10; s=s+a; n=n/10; } printf("Sum of digit is %d",s); getch(); }
Enter number: 155
Sum of digit is 11
Sum of digit is 11