Answered step by step
Verified Expert Solution
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
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started