+ 1

Write a program that prompts the user to enter 4 non-negative integer values and returns the largest of the four.

The values should not be larger than a n unsigned short int. If all the values are of the correct size, the output should be"the largest value so far is : If in the process of keying in values, the user keys in a value that is out of range, i.e. either a negative value or larger than the size of an unsigned short int as the first value, the output should be "the value is out of range/n the largest value so far is 0" If the user keys in several valid values then before the end of the process keys a value that is out of range, the output should be"the value entered is out of range! /n"The largest value so far is

7th Dec 2022, 7:01 PM
Mary Njeri
2 Respuestas
+ 5
we first define a constant maxValue that represents the maximum value that an unsigned short int can hold. We then prompt the user to enter four values, and store them in the variables val1, val2, val3, and val4. Next, we check each value to see if it is within the range of an unsigned short int. If it is not, we print an error message and return 0 to terminate the program. Otherwise, we compare the value to the current largest value (which is initially set to val1) and update it if necessary. Finally, after all four values have been entered and processed, we print the largest value so far. https://code.sololearn.com/cHcAXsYN9fyQ/?ref=app
9th Dec 2022, 11:50 AM
Sadaam Linux
Sadaam Linux - avatar
+ 3
Tag the language you need help with. Attach your code from the code playground.
7th Dec 2022, 8:12 PM
Ausgrindtube
Ausgrindtube - avatar