Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Wednesday, January 25
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw06and submit using the
- This is an electronic homework and you do not need to print out anything to turn in during class.
- Required reading: Sections 1 (The idea of a loop) and 2 (While loop examples) from the Unit 3 notes.
Write a program called
gauss.cthat reads an integer \(n\) from the user, and then uses a
whileloop to add up the numbers from 1 to \(n\) and print out the sum.
For example, if \(n=5\), then the result would be \(1+2+3+4+5\), which comes out to 15.
Example of running your program:
The sum of numbers from 1 up to 5 is 15
The sum of numbers from 1 up to 100 is 5050