24.5k views
4 votes
Given the following function definition fragment, for which values of myInt should the function be tested? int doSomething(int myInt) { if(myInt < 0) { //do some stuff here } return -1; }

User Garu
by
7.8k points

1 Answer

5 votes

Final answer:

The provided code defines a function in C++ that should be tested with both negative and non-negative values of the input parameter.

Step-by-step explanation:

The provided function definition fragment is in the programming language C++. The code snippet defines a function called do Something which takes an integer parameter called myInt.

To determine for which values of myInt the function should be tested, we need to analyze the code. In the given code, there is an if statement that checks whether myInt is less than 0. If it is, some code is executed. However, regardless of the value of myInt, the function always returns -1.

Therefore, it is sufficient to test the function with both negative and non-negative values of myInt. For example, you could test the function with myInt being -5, -1, 0, or any positive number.

User JackHang
by
7.9k points