Easy

You are given a two-digit integer n. Return the sum of its digits.

Example

For n = 29, the output should be
addTwoDigits(n) = 11.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] integer n

    A positive two-digit integer.

    Guaranteed constraints:
    10 ≤ n ≤ 99.

  • [output] integer

    • The sum of the first and second digits of the input number.

[C] Syntax Tips

// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
    char * answer = malloc(strlen(name) + 8);
    printf("This prints to the console when you Run Tests");
    strcpy(answer, "Hello, ");
    strcat(answer, name);
    return answer;
}

더보기

Solution

int addTwoDigits(int n)
{
	return n/10+n%10;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Candies  (0) 2020.04.07
<Codesignal> Largest Number  (0) 2020.04.07
<Codesignal> Sudoku  (0) 2020.04.06
<Codesignal> spiralNumbers  (0) 2020.04.06
<Codesignal> messageFromBinaryCode  (0) 2020.04.06

+ Recent posts