Questions 8 and 9 using C++!!! Safari File Edit View History Bookmarks Window He
ID: 2248280 • Letter: Q
Question
Questions 8 and 9 using C++!!!
Safari File Edit View History Bookmarks Window Help 3 R 89%n Mon 12:13 AM Q O E tu.blackboard.com kboard Texas Tech University Blackboard & as Welcome to the ECE-1305 Homepage at -20. https://ttu.blackboard.com/bbcswebcapid-300. Chegg Study Guided Solutions and Study Help ... IMG 2568.JPG Screen Shot 2017-07.36.31 PM Introduction to Electrical and Computer Engineering ECE-1305 C, 2017 n Shot Screen Shot 09.24.48 PM 2017-07.. 6.44 PM 8) Analyze the following code and provide the output. Explain your answer. double x = 0; while (X => 0) creen Shot 2017-2018 -09... 4.51 PM SUBLEA..ENT copy coutExplanation / Answer
Answer:
Problem 8:
The Code will give error in second line.
As condition in while loop is not correct. it must be "(x>=0)".
The sign > greater than must be followed by = equal to sign. Reverse is not valid.
Problem 9:
OUTPUT: 0 1 0 1 0 1 1
Code will assign values to variables as a=1, b=4, x=8, and y=0.
In second line of code, it will first check if value of 'a' is equal to 'b', If yes output will be '1' otherwise '0'.
here, condition is false, so output is '0' with space.
In third line of code, it will check (x!=b), as it is true, output is '1' with space.
In fourth line of code, it will check (b<=a), as it is false, output is '0' with space.
In fifth line, it will check ((y*b) <= !(x*a)) i.e. (0*4) <= !(8*1)
i.e 0 <= !8, as it is true, output is '1' with space.
In sixth line, it will check,!( (!a) == y), as it is false, output is '0' with space.
In seventh line ( (!y) && (!b) == (y) || (!a) )will check,
i.e (!y) && (!b) =
(!0) && (!4) = 1&&0 = 0 and
(y)||(!a)= 0||0 = 0
So, ( (!y) && (!b) == (y) || (!a)), = 0 == 0 which is true, so output is '1' with space.
In last line, it will check the condition, (x/b) >= 2*a = (8/4) >= 2*1 i.e. 2 >=2,
which is true, so putput is '1'
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.