ALICE IN THE WONDERLAND
Problem Description
Alice was bored that day,so she was sitting on the riverbank .Suddenly she notices a talking, White Rabbit with a pocket watch .It ran fast,and she followed it, down a rabbit hole .She fell into the hole and found a magical wonderland with dark trees, beautiful flowers.She found many ways numbered from 1,2,3,........18
She was confused which is the right way that will lead her to her home. She found a cute bird, standing in one of the tree. Alice asked the bird the way to go back to her home.The bird said a two digit number( say 23 ) and asked her to find the sum of its digits (2+3=5) and that numbered way will lead her to her home.Alice was already confused, so pls help Alice in finding the route to her home....
Input Format:
Input consists of an integer corresponding to the 2-digit number.
Output Format:
Output consists of an integer corresponding to the sum of its digits. Refer sample input and output for formatting specifications
CODING ARENA::
#include <stdio.h>
int main()
{
int n,t,r,s=0;
scanf("%d",&n);
if(n<99)
{
t=n;
while(t)
{
r=t%10;
s=s+r;
t=t/10;
}
printf("Alice must go in path %d",s);
}
else
{
printf("not a 2 digit number");
}
return 0;
}
Test Case 1
Input (stdin)23
Expected Output
Alice must go in path 5
Test Case 2
Input (stdin)123
Expected Output
not a 2 digit number
No comments:
Post a Comment