Write, compile, and execute a C++ program to calculate the sum of the numbers from 1 to 100. The formula for calculating this sum is sum = (n/2)(2*a + (n-1)d), where n = number of terms to be added, a = the first number, and d= the difference between each number. Your program should produce the display
The sum of the number is xxxx.
where the xxxx represents a field width of four digits and should be replaced by the sum computer by the program.

Recommended Answers

All 2 Replies

Have you tried some code? Hardly someone will help you if you don't show the code you are trying to do.

What have you done, besides posting your homework assignment?
Show your code to us and pinpoint the errors you have.
We will be more than happy to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.