CJCoding With Joseph

Sum of First N Numbers (input)

Read a single integer n from standard input, then use a loop to add up the numbers from 1 to n. Print the result in the format:

Sum: 15

For the input 5, the sum 1+2+3+4+5 is 15, so the program prints Sum: 15.

Expected Output:

Sum: 15
Topics:
Loops
๐Ÿ“ฅ Auto-Input:
5\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.