1+0 = 1
The sum of the digits is 6.
64
28
class Sum_Of_Digits { public static void printSumandnoofdigits(int n) { int temp = n; int count = 0; int sum = 0; while ( n > 0 ) { sum = sum + n % 10; n = n / 10; count ++; } System.out.println("The number is..." + temp ); System.out.println("The sum of digits is..." + sum); System.out.println("The number of digits is..." + count); } }
When the sum of the digits you are adding is 10 or larger.
10 9+9+1 = 19 1+9=10
enter the number whose digits are to be added num is the given value num=0! k=num%10 sum=sum=k k=num/10 num=k print the sum of the digits
1+0 = 1
The number 28 is a perfectly reasonable number. The sum of the digits of several numbers is 10. 19 for instance
The sum of the digits is 6.
#include <stdio.h> void main() { int digi,num,i,sum=0; printf("Enter the number of digits:"); scanf("%d",&num); while(i>0); { for(i=0;i<10000;i++) { digi=num; i=digi%10; sum=sum+i; num=digi/10; } printf("The sum of digits entered is %d",sum); } }
41.542.443.344.245.146
By the sum of its digits: 10. By each of its individual digits: 11.
# includevoid main(){int no,rem=0,sum=0,n; /*declaration*/printf("Enter 2 digit number:");scanf("%d",&no);for(n=1;n
64
64