Need help understanding something in one of the questions in my assignment. What are constraints?


Joined
Dec 7, 2021
Messages
2
Reaction score
0
In this challenge, you are required to calculate and print the sum of the 5 integers, keeping in mind that some of those integers may be quite large.

Input Format

You will take 5 different inputs on different lines and then store them in 5 different variables.

Output Format

Print the integer sum of all 5 variables.

Constraints

0 ≤ input numbers ≤ 1010

Sample Input

1000000001

1000000002

1000000003

1000000004

1000000005

Output

5000000015

C++ by the way.

Ok that's the question. It's pretty basic and I can do that. Just need help understanding constraints. The professor never talked about them at all. I get that your supposed have a minimum and maximum for input values (Am I right?) but how do you actually go about implementing that?

Pls help!
 
Ad

Advertisements

Joined
Mar 3, 2021
Messages
243
Reaction score
29
Yeah, that's a little... open ended. The constraints given don't match the input/output sections. I'd probably store the inputs and constraints as int64_t types, assuming the user won't put anything quite that absurdly large (9,223,372,036,854,775,807). Then, check if the values don't fit in the constraints. I guess if one doesn't, print a sensible error and return a non-zero instead of printing the output? If you need anything more, post what code you've got and we'll take a look.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top