This is a great starting point for anyone learning pseudocode. In Sum of Two Values, the goal is simple: you receive two separate numbers as input and your job is to find what happens when you add them together.
Think of it as a basic calculator. You take the first value, add the second one, and then return the total result. It’s a foundational exercise to help you get used to handling numbers and performing basic arithmetic in your algorithms.
For example, if the first number is 10 and the second is 20, your program should output 30. If they are 5 and -3, the result would be 2. It really is that straightforward!
Example Input & Output
A single element vacuously satisfies the alternating rule.
The sequence alternates even, odd, even, odd.
Two odd numbers appear consecutively.
Algorithm Flow

Solution Approach
This challenge is an introduction to the basic structure of a pseudocode program. A standard solution involves three main steps: declaration, input, and processing.
The kamus section is used for variable declaration, where we define x, y, and total as integers. In the algoritma section, we use input(x, y) to capture data, calculate the sum using the assignment operator <-, and finally display the result with output().
Best Answers
class Solution {
public boolean is_alternating(Object nums) {
int[] arr = (int[]) nums;
if (arr.length <= 1) {
return true;
}
for (int i = 0; i < arr.length - 1; i++) {
if ((arr[i] % 2) == (arr[i+1] % 2)) {
return false;
}
}
return true;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
