[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-170090-105":53,"doc-detail-170090-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","ece-2036-test-ii-open-book-cc-and-mbed-programming-questions","ECE 2036 Test II - Open book C/C++ and mbed programming questions","","ECE 2036 Test II contains multiple programming questions focused on C/C++ fundamentals and embedded C++ on an mbed platform. Topics include string operations with substr and output formatting in hex/decimal, exception handling with try/throw/catch, writing class templates for typed addition, selecting appropriate STL containers and iterators, implementing constructors/destructors for dynamic memory, and overloading stream output via friend operator\u003C\u003C. The test also covers an mbed game-like routine controlling LEDs and a speaker using bitwise logic, timing, and a circular shift display pattern.",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/ece-2036-test-ii-open-book-cc-and-mbed-programming-questions/170090/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/ece-2036-test-ii-open-book-cc-and-mbed-programming-questions/170090.png","ImageObject",442,249,{"name":88,"@type":89},"8796093062539","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/vnd.openxmlformats-officedocument.wordprocessingml.document","2026-10-14","2026-09-01",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",6,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"What do the first string-manipulation questions require students to determine?","Question",{"text":109,"@type":110},"They require students to compute the output of code using string concatenation, substr, and mixed hex/decimal printing, including character indexing and stream formatting.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"How should a template function be written to add two values of the same type?",{"text":114,"@type":110},"Define a class-template function that takes two parameters of template type and returns their sum using the + operator, e.g., AddEm(mytype a, mytype b) { return a+b; }.",{"name":116,"@type":107,"acceptedAnswer":117},"What logic controls when the speaker produces sound in the mbed program?",{"text":118,"@type":110},"The speaker is set to beep within the loop when value becomes 0 after XOR with the pushbutton input; it generates a tone at 2000 Hz, flashes LEDs according to the specified on/off timing pattern, then resumes the game sequence.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},170090,1790469367,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":60,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":101,"language":135,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":139,"read_time":73},8796093062539,"Name:__________________________________________     \tScore:_____________________\nECE 2036 Test II\nOpen book and notes, PCs and tablets allowed, but no Internet Access and code cannot be run on a PC\n(10%) Assuming the short C/C++ code segment below compiles, what is output?\nstring str(\"ECE 2036 \");\nstring mystr;\nstr = str + \"Test 2\";\nmystr = str.substr(6,5);\ncout \u003C\u003C mystr \u003C\u003C hex \u003C\u003C mystr.length() \u003C\u003C str[5] \u003C\u003C dec \u003C\u003C str.length();\ncout.put(0x31);\ncout\u003C\u003C endl;\nOutput: _____________36 Te50151___________________________________________________\n(5%) What does the following code print out?\n#include \u003Ciostream>\nusing namespace std;\nint main()\n{\ntry\n{\ncout \u003C\u003C \"Enter try block\" \u003C\u003C endl;\nthrow 2036;\ncout \u003C\u003C \"End try block\" \u003C\u003C endl;\nthrow 2031;\n}\ncatch (int a) { cout \u003C\u003C \"Error #\" \u003C\u003C a \u003C\u003C endl; }\n}\n(5%) Write a C/C++ template definition that automatically generates a function called “AddEm” that returns the sum of two values of the same type (i.e., for integers AddEm(2, 3) returns 5, or for doubles AddEm(3.0, 2.0) returns 5.0). You can assume that the “+” operator is defined for any type that is used with the template.\nTemplate \u003Cclass mytype>\nmytype AddEM( mytype a, mytype b) {\nreturn a+b;\n}\u000f\n(5%) The _____list_______ STL container is likely the most appropriate/efficient choice when new large items are frequently inserted or deleted (not only at the ends) and random access is never used.\n(5%) An _____iterator___________ is normally used instead of a standard C++ pointer to move between data objects that are held inside STL containers.\n(10%) If a new class definition needs dynamic memory allocation, the user also typically needs to\nprovide (i.e., not use the default) code for the classes’ _____constructor_________________, it creates the object using the C++ keyword __new__________. The classes’ __destructor________ needs to reclaim the heap memory used by the object using the C++ keyword _________delete_____.\n(10%) If you wrote a new class that was called “myclass”, write the additional statements needed to get a statement such as, “cout \u003C\u003C A;” (where A is a myclass object) to automatically work in a program as one would expect. The data to print out with cout is private in myclass and setup using “int value;”.\nAdd this line to myclass definition to make it a friend:\nfriend std::ostream& operator\u003C\u003C(ostream& output, const myclass rhs);\nostream& operator\u003C\u003C(ostream& output, const myclass rhs) {\noutput\u003C\u003Crhs.value;\nreturn output;\n}\nSee textbook page 441\n(5%) Why would using only the default constructor not work correctly in the matrix class from the matrix calculator lab and what could happen if it ran forever?\nSince dynamic memory allocation is used for a matrix (the size is not known at compile time) you must supply the constructor and destructor to avoid memory allocation errors and leaks.\n(20% - 5% each part) Answer the following questions about the mbed program attached at the end of the test. A speaker is connected to p21 and a pushbutton is connected to p14. The pushbutton reads a “0” until it is held down for a “1”. The program is a retro version of one of the very first computer games.\nExplain what the display function does, using the value 0x0A as an illustrative example?\nIt sends the low 4-bits of the value in binary to the four LEDs. With 0x0A the binary pattern seen in the four LEDs would be 1010 or ON OFF ON OFF.\nWhat would you notice watching the mbed module, assuming that the pushbutton is never hit?\nThe pattern on the LEDs circular shifts to the left every .25 seconds.\nIn the program, what condition on a variable is needed to make the speaker produce a sound, describe the sound that is made and what do the LEDs do when the speaker makes a sound?\nWhen value = 0 the speaker beeps a 2000Hz tone and LEDs flash on for .5 seconds, off for .25 seconds five times and then it restarts.\nExplain in simple terms the pushbutton strategy needed to win the game once it starts (i.e., produce a sound on the speaker)? Hint: Recall from 2030 that","cbCaiooMPVswQb5Z","https://ap.wps.com/l/cbCaiooMPVswQb5Z","docx",85825,"English","# ECE 2036 Test II\n## C/C++ code output and exception handling\n## Templates, STL containers, iterators\n## Constructors/destructors and operator overloading\n## mbed LEDs and speaker retro-game logic\n## Inheritance and polymorphism output","[{\"question\":\"What do the first string-manipulation questions require students to determine?\",\"answer\":\"They require students to compute the output of code using string concatenation, substr, and mixed hex/decimal printing, including character indexing and stream formatting.\"},{\"question\":\"How should a template function be written to add two values of the same type?\",\"answer\":\"Define a class-template function that takes two parameters of template type and returns their sum using the + operator, e.g., AddEm(mytype a, mytype b) { return a+b; }.\"},{\"question\":\"What logic controls when the speaker produces sound in the mbed program?\",\"answer\":\"The speaker is set to beep within the loop when value becomes 0 after XOR with the pushbutton input; it generates a tone at 2000 Hz, flashes LEDs according to the specified on/off timing pattern, then resumes the game sequence.\"}]","ECE 2036 Test II - Open book C/C++ and mbed programming questions | DOCX",1788267321]