Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ please follow instructions and fix the errors and please make a comment next to each code error you fix. Below are 25 code

in c++ please follow instructions and fix the errors and please make a comment next to each code error you fix.

  • Below are 25 code fragments, inserted into a try catch block.
  • Each line has zero or more errors. Your task is to find and remove all errors in each fragment.
    • Do not fix problems by simply deleting a statement; repair the problems by changing, adding, or deleting a few characters.
    • There may be different ways to fix them
    • You may need to rename variables to avoid re-declaration errors
    • When you fix a line, it should print out "Success!" and then a newline.
  • You may want to comment out each line that you have not fixed yet in order to get it to compile, so you can test as you go
  • In the end you should see a total of 25 "Success!" outputs

#include "std_lib_facilities.h" int main() try { //1. Cout << "Success! "; //2. cout << "Success! ; //3. cout << "Success" << ! " //4. cout << success << ' '; //5. string res = 7; vector v(10); v[5] = res; cout << "Success! "; //6. vector v(10); v(5) = 7; if (v(5)!=7) cout << "Success! "; //7. if (cond) cout << "Success! "; else cout << "Fail! "; //8. bool c = false; if (c) cout << "Success! "; else cout << "Fail! "; //9. string s = "ape"; boo c = "fool" v(5); for (int i=0; 0 v(5); for (int i=0; i<=v.size(); ++i) ; cout << "Success! "; //15. string s = "Success! "; for (int i=0; i<6; ++i) cout << s[i]; //16. if (true) then cout << "Success! "; else cout << "Fail! "; //17. int x = 2000; char c = x; if (c==2000) cout << "Success! "; //18. string s = "Success! "; for (int i=0; i<10; ++i) cout << s[i]; //19. vector v(5); for (int i=0; i<=v.size(); ++i) ; cout << "Success! "; //20. int i=0; int j = 9; while (i<10) ++j; if (j s = "Success! "; for (int i=0; i<=10; ++i) cout << s[i]; //23. int i=0; while (i<10) ++j; if (j

keep_window_open(); return 0; } catch (exception& e) { cerr << "error: " << e.what() << ' '; keep_window_open(); return 1; } catch (...) { cerr << "Oops: unknown exception! "; keep_window_open(); return 2; }

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions