Erster Commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// 531 ---> 531 / 10 = 53
|
||||
// units 1
|
||||
// tens = 3
|
||||
// hundreds = 5
|
||||
|
||||
int main()
|
||||
{
|
||||
int num;
|
||||
int units, tens, hundreds;
|
||||
|
||||
printf("Enter a 3-digit number: ");
|
||||
scanf("%d", &num);
|
||||
|
||||
units = num % 10;
|
||||
tens = (num / 10) % 10;
|
||||
|
||||
hundreds = num / 100;
|
||||
|
||||
printf("The total sum of digits in %d is %d\n", num, units + tens + hundreds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user