You can use a for loop to iterate through the numbers from 1 to 10 and add them together. Here's an example code block:
main.cs130 chars7 lines
In this code, we initialize a variable sum
to 0, then use a for loop to iterate through the numbers 1 to 10. For each number, we add it to sum
. After the loop is finished, we print the value of sum
to the console. The output should be:
main.cs43 chars2 lines
gistlibby LogSnag