[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-782745-105":3,"detail-sidebar-cat-0-en-105":79,"doc-detail-782745-en":129,"doc-similar-782745":161},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":72,"head_meta":74,"extra_data":76,"updated_unix":78},105,"en","spring-16-exam-kaist-answers","Spring 16 Exam - KAIST Answers","","Spring Semester 2016 KAIST EE209 mid-term examination assesses programming structures for electrical engineering through C programming, data representation, pointers, memory management, debugging, and string processing. The paper sets a 140-minute, closed-book assessment and lists seven questions with point allocations. Visible problems test code-output reasoning, binary and integer conversions, case-insensitive substring search, swapping values and pointers, and identifying memory-allocation errors. Answer cues accompany several questions, supporting review of C behavior and exam-style problem solving.",{"@graph":14,"@context":71},[15,34,54],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/exam/","Exam",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/spring-16-exam-kaist-answers/782745/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":48,"encodingFormat":47,"isAccessibleForFree":49,"interactionStatistic":50},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/spring-16-exam-kaist-answers/782745.png","ImageObject",300,407,{"name":42,"@type":43},"AfterMidnight","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-12-03",true,{"@type":51,"interactionType":52,"userInteractionCount":26},"InteractionCounter",{"@type":53},"ViewAction",{"@type":55,"mainEntity":56},"FAQPage",[57,63,67],{"name":58,"@type":59,"acceptedAnswer":60},"How long is the examination, and what materials are allowed?","Question",{"text":61,"@type":62},"The exam lasts 140 minutes and is closed book and notes.","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"What C programming topics are assessed?",{"text":66,"@type":62},"Visible questions cover code output, number representation, string searching, pointer and value swapping, and dynamic memory allocation and debugging.",{"name":68,"@type":59,"acceptedAnswer":69},"What are the requirements for implementing strcasestr()?",{"text":70,"@type":62},"The function must search for a substring without considering case. It may use toupper() or tolower(), but no other C runtime library functions.","https://schema.org",{"og:url":32,"og:type":73,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":75,"canonical":32},"index,follow",{"doc_id":77,"site_id":7},782745,1796313779,{"code":4,"msg":80,"data":81},"success",[82,86,90,93,98,103,108,113,118,121,125],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":83,"show_sort_weight":84,"slug":85},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":87,"show_sort_weight":88,"slug":89},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":91,"slug":92},70,"exam",{"id":94,"doc_module":4,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},5,"Comic",60,"comic",{"id":99,"doc_module":4,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},6,"Technology",50,"technology",{"id":104,"doc_module":4,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},7,"Healthcare",40,"healthcare",{"id":109,"doc_module":4,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},8,"Research & Report",30,"research-report",{"id":114,"doc_module":4,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},9,"Religion & Spirituality",20,"religion-spirituality",{"id":116,"doc_module":4,"doc_module_name":25,"category_name":119,"show_sort_weight":116,"slug":120},"World Cup","world-cup",{"id":122,"doc_module":4,"doc_module_name":25,"category_name":123,"show_sort_weight":122,"slug":124},10,"Lifestyle","lifestyle",{"id":126,"doc_module":4,"doc_module_name":25,"category_name":127,"show_sort_weight":94,"slug":128},19,"General","general",{"code":4,"msg":80,"data":130},{"doc_id":77,"user_id":131,"nickname":42,"user_avatar":132,"doc_module":4,"category_id":33,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":26,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":138,"language":139,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":12,"update_tm":78,"read_time":143,"preview_page_count":33,"preview_urls":144},962090896061,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","Spring Semester 2016  \nKAIST EE209  \nProgramming Structures for Electrical Engineering  \nMid-term Exam  \nName:    \nStudent ID:    \nThis exam is closed book and notes. Read the questions carefully and focus your answers on what has been asked. You are allowed to ask the instructor/TAs for help only in understanding the questions, in case you find them not completely clear. Be concise and precise in your answers and state clearly any assumption you may have made. You have 140 minutes (1:00 PM – 3:20 PM) to complete your exam. Be wise in managing your time. Good luck.  \nQuestion 1  / 25   \nQuestion 2  / 15   \nQuestion 3  / 20   \nQuestion 4  / 15   \nQuestion 5  / 15   \nQuestion 6  / 10   \nQuestion 7  / 15   \n1. (25 points) Small Programs  \n􀁺 Assume that we have included proper header files (e.g., \u003Cstdio.h>) .  \n􀁺 Assume that we are using 64-bit OS.  \n(a) (5 points) What’s the output of this code snippet?  \nunsigned int i = 0xFF000000;  \nchar x = (char) i;  \nprintf(“x = %d\\n”,(int)x);  \n􀃖 x = 0  \n(b) (5 points) What’s the output of this code snippet?  \nint x = 1;  \nif (x = 0) {  \nprintf(“x is 0, x=%d\\n”, x);  \n} else {  \nprintf(“x is not 0, x=%d\\n”, x);  \n}  \n􀃖 x is not 0, x=0  \n(c) (5 points) What’s the output of this code snippet?  \n(%zu takes an unsigned long integer)  \nchar *x = “Hello World\\n”;  \nchar y[] = “Hello World\\n”;  \nchar **z = &x;  \nprintf(“1:%zu 2:%zu 3:%zu 4:%zu 5:%zu\\n”,  \nsizeof(x), sizeof(y), sizeof(z),  \nsizeof(*x), sizeof(*z));  \n􀃖 1:8 2:13 3:8 4:1 5:8  \n(d) (5 points) What’s the output of this code snippet?  \nvoid f(int x)  \n{  \nif (x /10) f (x/10);  \nif (x % 10) putchar (‘0’ + x % 10);  \n}  \n…  \nf(30405);  \n􀃖 345  \n(e) (5 points) What’s the output of this code snippet?  \nint i, j;  \ni = 100;  \nj = 200;  \ni = i ^j;  \nj = i ^j;  \ni = i ^j;  \nprintf(“i=%d, j=%d\\n”, i, j);  \n􀃖 i=200, j=100  \n2. (15 points) A C runtime library function, strstr(), finds a substring in a string. That is, char * strstr(const char* haystack, const char* needle);  \nfinds a substring, needle, in the string, haystack and returns the starting address of the substring (or NULL if there is no such substring) .  \nUnfortunately, strstr() is case-sensitive, so in the code snippet below,  \nchar *x = “hello world\\n”;  \nchar *p1, *p2;  \np1 = strstr(x,“WoRLd”);  \np1 will be NULL, since x does not contain “WoRLd”.  \nHere, we want to write a case-insensitive version of strstr() called strcasestr() whose function prototype is  \nchar * strcasestr(const char* haystack, const char* needle);  \nand  \np2 = strcasestr(x,“WoRLd”);  \np2 will point to the address of ‘w’ in x.  \nPlease fill in the function body in the next page. For brevity, we have renamed the parameter names to s (haystack) and n (needle) . That is, you need to find n in s without considering its case. Note that you can’t call any C runtime library functions except toupper() or tolower(), but you can define and call your own functions outside strcasestr() . For brevity, you can assume both s and n are non-null, that is, you don’t need to check if they are NULL. Your code should compile without any errors or warning messages with gcc209 .  \nYou can use these C runtime library functions. No need to include a header file. int toupper(int c);  \nint tolower(int c);  \nint match(const char* s1, const char* s2){  \nwhile (*s2) {  \nif (*s1 == ‘\\0’)  \nreturn 0;  \nif (toupper((int)*s1) != toupper((int)*s2)) return 0;  \ns1++; s2++;}  \nreturn 1;}  \nchar *strcasestr(const char *s, const char *n){  \nif (*n == ‘\\0’) return NULL;  \nwhile (*s) {  \nif (match(s, n)) return (char *)s;  \ns++;}  \nreturn NULL;}  \n3. (20 points) Number System  \n(a) (5 points) short i = (short)-123;  \nRepresent i in the binary format (assume short int is 16 bits)  \n􀃖 11111111 10000101  \n(b) (5 points) What’s the output of this code snippet?  \nshort i = 32768;  \nprintf(“i = %hd\\n”, i-1);  \n􀃖 i = 32767  \n(c) (5 points) What’s the output of this code snippet?  \nprintf(“val = %hu\\n”,(unsigned short)-1);  \n􀃖 val = 65535  \n(d) (5 points) Wh","cbCaicOmpKqQF3ex","https://ap.wps.com/l/cbCaicOmpKqQF3ex","pdf",230380,14,"English","# Small Programs\n# Number System\n# Swap Functions\n# Dynamic Memory Allocation and Debugging","[{\"question\":\"How long is the examination, and what materials are allowed?\",\"answer\":\"The exam lasts 140 minutes and is closed book and notes.\"},{\"question\":\"What C programming topics are assessed?\",\"answer\":\"Visible questions cover code output, number representation, string searching, pointer and value swapping, and dynamic memory allocation and debugging.\"},{\"question\":\"What are the requirements for implementing strcasestr()?\",\"answer\":\"The function must search for a substring without considering case. It may use toupper() or tolower(), but no other C runtime library functions.\"}]","Spring 16 Exam - KAIST Answers | PDF",35,[145,149,153,157],{"page_no":22,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/3564a158337e7ed416a8420925b8d895.webp",983,1390,{"page_no":26,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/d15568d89912501206f85ee35b12f1b0.webp",982,1388,{"page_no":30,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/392e648bcea4e3e3fb96d14476a33897.webp",981,1387,{"page_no":33,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/d255b840a0e780155b5e6ebadd2c672c.webp",980,1385,{"list":162,"token":11},[163,170,175,182,188,195,201,207,214,221],{"doc_id":164,"doc_title":165,"file_type":136,"home_preview_img_url":166,"slug":167,"view_count":168,"category_name":29,"create_tm":169},391771,"C++ Programming Interview Questions - Part 1","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917406194/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=RmQOQc1znzQoaYq%2FIfc%2FrWHpQPM%3D","c-programming-interview-questions-part-1",15,1790358624,{"doc_id":171,"doc_title":172,"file_type":136,"home_preview_img_url":173,"slug":174,"view_count":168,"category_name":29,"create_tm":169},391772,"71 C++ Interview Questions to Ask Your Applicants","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917705862/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=PPIzV9G1%2BAu9BQSO6IuoSywYTC0%3D","71-c-interview-questions-to-ask-your-applicants",{"doc_id":176,"doc_title":177,"file_type":136,"home_preview_img_url":178,"slug":179,"view_count":180,"category_name":29,"create_tm":181},391265,"HCL Placement Papers - Section II-C Programming - C Questions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917371012/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=7%2FEhzu1g5MMgNhVWdn0cunScRNw%3D","hcl-placement-papers-section-ii-c-programming-c-questions",11,1790350498,{"doc_id":183,"doc_title":184,"file_type":136,"home_preview_img_url":185,"slug":186,"view_count":180,"category_name":29,"create_tm":187},470493,"AP Computer Science A Course and Exam Description - Exam Information V.1 - Sample Exam Questions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926578912/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=nfFZl9azpvZg3o9RGmrczaCRmiI%3D","ap-computer-science-a-course-and-exam-description-exam-information-v1-sample-exam-questions",1790777366,{"doc_id":189,"doc_title":190,"file_type":136,"home_preview_img_url":191,"slug":192,"view_count":193,"category_name":29,"create_tm":194},501607,"Teach Yourself C++ in 21 Days - Fifth Edition","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229931378078/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=BAZIC8W3cX%2Bm%2BSilrGkK0M3I4nw%3D","teach-yourself-c-in-21-days-fifth-edition",18,1791021431,{"doc_id":196,"doc_title":197,"file_type":136,"home_preview_img_url":198,"slug":199,"view_count":30,"category_name":29,"create_tm":200},728611,"W4 Exam - JamCoders Week 4 Exam July 30, 2026","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230030203011/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=Br3kY3ttK6IbL5gXEu1zymV3SYo%3D","w4-exam-jamcoders-week-4-exam-july-30-2026",1795292664,{"doc_id":202,"doc_title":203,"file_type":136,"home_preview_img_url":204,"slug":205,"view_count":138,"category_name":29,"create_tm":206},496279,"6.100A Final Review","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229929810430/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=%2BhdE15CEpLkQKa3oYmmg%2BsfIqF0%3D","6100a-final-review",1790930269,{"doc_id":208,"doc_title":209,"file_type":136,"home_preview_img_url":210,"slug":211,"view_count":212,"category_name":29,"create_tm":213},395335,"CCA - Computer Fundamentals - Exam Syllabus","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229918633304/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=GPVTk%2F1dawF0DIe9as3DIpem1DA%3D","cca-computer-fundamentals-exam-syllabus",17,1790418120,{"doc_id":215,"doc_title":216,"file_type":136,"home_preview_img_url":217,"slug":218,"view_count":219,"category_name":29,"create_tm":220},391248,"HCL Interview Questions for Freshers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917655514/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=mNGmxpQnyEurDbyxEqi45A1euGw%3D","hcl-interview-questions-for-freshers",28,1790350372,{"doc_id":222,"doc_title":223,"file_type":136,"home_preview_img_url":224,"slug":225,"view_count":180,"category_name":29,"create_tm":226},300758,"Foundation Exam Reference Sheet - stdlib.h Functions - malloc calloc realloc free srand rand abs atoi atof - math.h Functions - pow sqrt fabs exp log - string.h Functions - strcmp strlen strcpy strcat - Summation Formulas","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229905867718/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354519&Signature=09ze3khkRtwVAx%2BFkt5U5D0Em7c%3D","foundation-exam-reference-sheet-stdlibh-functions-malloc-calloc-realloc-free-srand-rand-abs-atoi-atof-mathh-functions-pow-sqrt-fabs-exp-log-stringh-functions-strcmp-strlen-strcpy-strcat-summation-formulas",1789777134]