### About this program:

In this program, we are going to take any two digit number from the user and calculate the sum of its individual digits. Look at the below example for better understanding.

**Ex:** If you give 28

The output will be 10 (2+8).

**Sum of individual digits of a three digit number.**

### Logic:

Here is the logic behind this program. Take any two digit number. Divide it with 10. The 1st digit is the quotient and the 2nd digit is the remainder.

**(i)** Take a number from the user(n). Suppose here n=28.

To get the first digit, divide n with 10 and assign the quotient to a variable (a). a=n/10.

Ex: n=28

a=28/10

a=2

**(ii)** Now to get another digit, do n%10 and assign it to another variable (b). b=n%10.

Ex: n=28

b=28%10

b=8

**(iii)** So, a=2 and b=8. Add a and b and assign it to a variable (s). s=a+b

Ex: s=a+b

s=2+8

s=10

This is the final result. Now we just have to display the value of ‘s’.

### CODE:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#include<stdio.h> #include<conio.h> int main() { int a,b,n,s; printf ("Enter a two digit number :"); scanf ("%d",&n); a=n/10; b=n%10; s=a+b; printf("sum of digits of the number is: %d", s); getch(); return 0; } |

### OUTPUT:

1 2 |
Enter a two digit number: 36 Sum of digits of the number is: 9 |