Question: Your code should print the numbers 5,8,4 and 2 to the screen, each in its own separate output line. Then, the code should add all
Your code should print the numbers 5,8,4 and 2 to the screen, each in its own separate output line. Then, the code should add all of the numbers and display their sum to the screen, on yet another output line.
The output of your code should look like this:
5
8
4
2
19
Please do this in 3 ways:
Without using variables at all.
Using 4 independent variables (one for each number) and another variable for the sum.
Reusing the same variable for the numbers and an additional variable for the sum.
How can i write this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
