Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

python programming.. - Write a program in which displays the sum of the first 50

ID: 3759623 • Letter: P

Question

python programming..

- Write a program in which displays the sum of the first 50 integers , modify the program so that the user can specify how many integers to sum. For example, if the user enters 5, the program returns the sum of the first 5 integers.

-Define a function that has a single parameter and returns a magic number. The magic number is calculated by multiplying the parameter value by 34 and dividing it by 4. Call the function 3 times with 3 different values and display the result each time.

Explanation / Answer

#include <iostream>
using namespace std;

int main()
{
int positiveInteger;
int startingNumber = 1;

cout << "Please input an integer upto 100." << endl;

cin >> positiveInteger;

int result = 0
for (int i=startingNumber; i <= positiveInteger; i++)
{
result += i
cout << result;
}

cout << result;

return 0;

}