Code Logo

Sum Three Numbers

Published at19 Apr 2026
Calculations & Math Easy 8 views
Like0

Given three integers, compute their sum and return the result. The sum is the total when all three numbers are added together.

For example, the sum of 2, 4, and 6 is 2 + 4 + 6 = 12. The sum of -5, 0, and 5 is 0. The sum of 100, 200, and 300 is 600. If all three numbers are zero, the sum is 0.

Adding numbers is the most fundamental arithmetic operation. This problem tests your ability to receive multiple inputs, perform addition, and return a result. The order of addition does not matter because addition is commutative and associative. You can add the first two numbers, then add the third to the total.

In pseudocode, this is as simple as writing the expression a + b + c. Most languages evaluate this left to right, computing (a + b) first, then adding c. The result is returned to the caller.

Edge cases include negative numbers (which correctly reduce the total), zero values (which do not affect the sum), and large numbers where the sum might exceed typical integer ranges. For the constraints of this problem, standard integer arithmetic is sufficient.

Learn about our pseudocode specification
Guide

Example Input & Output

Example 1
Input
a = 2, b = 3, c = 4
Output
9
Explanation

2 + 3 + 4 = 9.

Example 2
Input
a = -2, b = 7, c = 1
Output
6
Explanation

-2 + 7 + 1 = 6.

Example 3
Input
a = 10, b = 0, c = 5
Output
15
Explanation

10 + 0 + 5 = 15.

Algorithm Flow

Recommendation Algorithm Flow for Sum Three Numbers

Solution Approach

Add all three numbers together using the addition operator and return the result.

function sumThree(a, b, c)
  return a + b + c

Compute a + b + c by using the + operator between each pair. The expression is evaluated left to right as (a + b) + c. The total is returned directly to the caller. No loops, conditions, or temporary variables beyond the implicit result are needed. This is the simplest possible function that performs arithmetic on multiple inputs.

Time complexity is O(1) since addition is a constant-time CPU operation regardless of the values being added. Space complexity is O(1).

Best Answers

Pseudocode - Approach 1
program sum_three_numbers
dictionary
   a, b, c, sum: integer
algorithm
   input(a, b, c)
   sum <- a + b + c
   output(sum)
endprogram