Question: Create a function called sumTo which takes an integer parameter and returns the total of all of the numbers from 1 to that number. For

Create a function called sumTo which takes an integer parameter and returns the total of all of the numbers from 1 to that number. For example, if the user entered a 5, the function would calculate 1 + 2 + 3 + 4 + 5 = 15. Keep prompting the user for a number until a zero (0) is entered. Use the following run as an example: Please enter a number from 3 to 100: 100 2, 4, 8, 16, 32, 64 The answer is 64

#include

#include using namespace std;

/* Type your code here. */

int main() { int num; cout << "Please enter a number from 3 to 100: ";

cin >> num; cout << num << endl; if ((num < 3) || (num > 100)) cout << "Please follow the directions!" << endl;

else { int answer = powerOfTwo(num); cout << "The answer is " << answer << endl; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!