Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design an algorithm and write its C++ code. that takes one positive integer argument, call it my_goal and returns as its value the smallest positive

Design an algorithm and write its C++ code. that takes one positive integer argument, call it "my_goal" and returns as its value the smallest positive integer n for which 1+2+3+. . . +n is at least equal to my_goal.

The solution must also check that the input is a positive integer and otherwise it should print an error message:

The '9' should outcome '4' because 1+2+3+49 and 1+2+3<9;

The '21' should outcome '6' because 1+2+3+4+5+621 and 1+2+3+4+5<21;

Keep your code commented and indented for ease of reading. Paste your commented codes in the solution and also add a clear screen shot of outcome in your solution.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago