Question: 5. Consider the following C/C++ program: #include int main) ( float x = -0.2; while ( x != 0.2 ) x += 0.01; printf done!

 5. Consider the following C/C++ program: #include int main) ( float

5. Consider the following C/C++ program: #include int main) ( float x = -0.2; while ( x != 0.2 ) x += 0.01; printf "done! " return 0 The program compiles without warnings or errors. However, when run it never outputs anything and does not terminate. It appears to go into an infinite loop. Why? What is the bug in the program? 6. A CMPT214 student has a script named check file.sh that contains, in part, the following lines: # Make sure that the source file exists if test -e $1 then echo "$1 must exist in the current working directory" 1>&2 exit 3 fi Unfortunately, the script has problems handling certain kinds of input. For example, consider the fol lowing computer interaction by the student: bash-3.2$ 1s The Big Deal The Big Deal bash-3.2$ sh check file.sh "The Big Deal" check file.sh: line 22: test: too many arguments bash-3.2$ sh -x check file.sh "The Big Deal" +test e The Big Deal check file.sh: line 22: test: too many arguments where ". . . stands for additional but irrelevant output, why is this error occurring? How can the error be solved without changing the logic/intent of the script? Note that marks will be deducted for re- porting a non-error or "correcting" something that is not in error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!