Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Had some trouble finding all the errors in this C++ code. Problem 2: Finding Errors [6 P The code to be examined contains at least

student submitted image, transcription available below

Had some trouble finding all the errors in this C++ code.
 

Problem 2: Finding Errors [6 P The code to be examined contains at least one error (one example error is given in Code 1): Example Code 1 Line Command 1 2 3 4 int main() { int a=0; double threshold = 10 For example: a semicolon is missing here std::cin >> a; if (a>>threshold) { else{ 6 7 8 9 } 10 } std::cout < < "a is greater than the threshold"; std::cout < < "a is smaller than or equal to the threshold"; Code to be Examined: Command #include Line 1 2 3 4 }; struct Values { double a = 0, b = 0; double Multiplying Values (Values z) { double y = x.a * x.b; return y; double DividingValues (Values g) { double y = 0; if (g.b (double)0) y = g.ag.b; else std::cout < < "Division by zero error" < < std::endl; return g; 5 6 7 8 } 9 10 11 12 13 14 } 15 int main() { 16 Values x; 17 18 19 20 21 22 23 } std::cout < < "Define value for a = "; std::cin >> x.x; std::cout < < "Define value for b = "; std::cin >> x.y; std::cout < < "b times a = " < < MultiplyValues(x) < < std::endl; std::cout < < "b divided by a = " < < DivideValues(x) < < std::endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Error 1 Missing Semicolon Line 6 In the MultiplyingValues function C double y xaxb Missing semicolon Theres a missing semicolon after this line A semi... 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_2

Step: 3

blur-text-image_3

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

Principles Of Econometrics

Authors: R Carter Hill, William E Griffiths, Guay C Lim

5th Edition

1118452275, 9781118452271

More Books

Students also viewed these Operating System questions