Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions