
Write a function that says whether the product n * size fits in a size_t, writing that product through out when it fits and leaving out alone when it does not.
checked_size(1000, 24, &out)Expected result
1
24000For your own tracking. Tests grade your code.
checked_size(0, 8, &out)Expected result
1
0checked_size(3, SIZE_MAX / 3, &out)Expected result
1
18446744073709551615checked_size(SIZE_MAX, SIZE_MAX, &out)Expected result
0checked_size(SIZE_MAX, 2, &out) with out = 777, out printed either wayExpected result
0
777Expected files
checked_size.cAllowed functions
None. Write every helper yourself.
Allowed headers

v0.40: Create exercises. Challenge the community.
Meet Studio →Write a function that says whether the product n * size fits in a size_t, writing that product through out when it fits and leaving out alone when it does not.
checked_size(1000, 24, &out)Expected result
1
24000For your own tracking. Tests grade your code.
checked_size(0, 8, &out)Expected result
1
0checked_size(3, SIZE_MAX / 3, &out)Expected result
1
18446744073709551615checked_size(SIZE_MAX, SIZE_MAX, &out)Expected result
0checked_size(SIZE_MAX, 2, &out) with out = 777, out printed either wayExpected result
0
777Expected files
checked_size.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.