Mr.James planned to go Godzilla vs Kong movie in iMax with his wife. There was as competition going on in the theare complex for couples. If a particular couple solves the task given to them then they will get the tickets for the movie free of cost.
The task is nothing but to find the sum of digits of the number provided to them.
Can you help James and his wife with the task so that they will get the free tickets?
Input:
Only line of input has single integer representing n.
Output:
Print the sum of digits of the number.
#include <stdio.h> int sum(int num) { if(num!=0) return (num%10+sum(num/10)); else return 0; } union Data { int num,res; }data; int main() {//printf("n-number: "); scanf("%d",&data.num); data.res=sum(data.num); //printf("sum= "); printf("%d",data.res); return 0; }
INPUT_1:
567
OUTPUT:
18
INPUT_2:
98
OUTPUT:
24
INPUT_3:
333
OUTPUT:
9
INPUT_4:
555
OUTPUT:
15
ILLUSTRATION
Morae Q!
- Find how long will it take till the next fortune year from the current year.
- Find if it’s possible to distribute all the crayons into boxes and satisfy all the conditions.
- Compute sum of numbers using call by reference.
- Compute the amount of money to be handed over with conditions.
- Find the total number of beautiful triplets in the sequence.
- Find the total amount each worker has to pay individually.
- Find the minimum distance between any pair of equal elements in the array.
- Compute the maximum possible value of the given equation.
- Find the age of the student at the time of joining.
- Compute the total number of photos at each restaurant .
- Find the sum of digits of the number using Union datatype.
- Generate the details of the novels in the expected format.
- Sort the student details based on their names in ascending order.
- Find a way to move the king from current position to different square on chessboard.
- Find the time differences in the two different time zones.
- Identifying the greatest number with a numerator and denominator.
- Find the Minimum number of packages to supply all the bases.
- Tower of Hanoi, A puzzle.
- Compute the sum of array of elements using recursion method.
- Find the super digit of an integer using the rules.