[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-391774-105":59,"doc-detail-391774-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","c-interview-questions-and-answers-interview-questions","C Interview Questions and Answers - Interview Questions","","A set of C programming interview questions with concise answers and explanations covering core language concepts and practical problem solving. Topics include the purpose and behavior of C such as standardized origins, the printf() output and formatting pitfalls, and memory management using malloc() versus calloc(). It also addresses differences between printf() and sprintf(), linked-list cycle detection logic, union behavior, static variable storage semantics, macro advantages over functions, and key C storage-class ideas.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":20,"@type":76,"position":81},"https://docshare.wps.com/document/exam/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/c-interview-questions-and-answers-interview-questions/391774/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/c-interview-questions-and-answers-interview-questions/391774.png","ImageObject",300,407,{"name":92,"@type":93},"Jordan Avery","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-10-26","2026-09-25",true,{"@type":102,"interactionType":103,"userInteractionCount":39},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is the difference between calloc(...) and malloc(...)?","Question",{"text":112,"@type":113},"calloc(...) allocates memory for an array and initializes it to 0, while malloc(...) allocates a specified number of bytes without initializing the memory.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What happens when printf(\"%d\") is called with no matching argument?",{"text":117,"@type":113},"With only %d in the format string and no corresponding argument, the compiler accesses an expected value from the stack and prints whatever data happens to be at that memory location, leading to garbage output.",{"name":119,"@type":110,"acceptedAnswer":120},"How can you check whether a linked list is circular?",{"text":121,"@type":113},"Use two pointers starting at the head, move one step for pointer1 and two steps for pointer2, and detect a meeting point indicating a cycle.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},391774,1791166937,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":19,"category_name":20,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":39,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":144,"read_time":36,"preview_page_count":4},1099523882367,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","[http://TechPreparation.com](http://TechPreparation.com)  \nC Interview Questions  \nAnd Answers  \n2008  \nV i s i t [T e c h P r e p a r a t i o n . c o m](T e c h P r e p a r a t i o n . c o m) f o r m o r e i n t e r v i e w q u e s t i o n s a n d  \na n s w e r s  \nC Interview Questions and Answers  \nWhat is C language?  \nThe C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C is prized for its efficiency , and is the most popular programming language for writing system software, though it is also used for writing applications.  \nprintf() Function  \nWhat is the output of printf(\"%d\")?  \n1. When we write printf(\"%d\",x); this means compiler will print the value of x. But as here, there is nothing after %d so compiler will show in output window garbage value.  \n2. When we use %d the compiler internally uses it to access the argument in the stack ( argument stack) . Ideally compiler determines the offset of the data variable depending on the format specification string. Now when we write printf(\"%d\",a) then compiler first accesses the top most element in the argument stack of the printf which is %d and depending on the format string it calculated to offset to the actual data variable in the memory which is to be printed. Now when only %d will be present in the printf then compiler will calculate the correct offset (which will be the offset to access the integer variable) but asthe actual data object is to be printed is not present at that memory location so it will print what ever will be the contents of that memory location.  \n3. Some compilers check the format string and will generate an error without the proper number and type of arguments for things like printf(...) and scanf(...) .  \nVisit [http://TechPreparation.com](http://TechPreparation.com for more)[ for more](http://TechPreparation.com for more) Interview Questions with Answers Page 2  \nmalloc() Function-What is the difference between \"calloc(...)\" and\"malloc(...)\"?  \n1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * size) .  \nmalloc(...) takes in only a single argument which is the memory required in bytes. malloc(...) allocated bytes of memory and not blocks of memory like calloc(...) .  \n2. malloc(...) allocates memory blocks and returns a void pointer to the allocated space, or NULL if there is insufficient memory available.  \ncalloc(...) allocates an array in memory with elements initialized to 0 and returns a pointer to the allocated space. call oc(...) calls malloc(...) in order to use the C++ _set_new_mode function to set the new handler mode.  \nprintf() Function-What is the difference between \"printf(...)\" and\"sprintf(...)\"?  \nsprintf(...) writes data to the character array whereas printf(...) writes data to the standard output device.  \nCompilation How to reduce a final size of executable?  \nSize of the final executable can be reduced using dynamic linking for libraries.  \nLinked Lists--Can you tell me how to check whether a linked list is circular?  \nCreate two pointers, and set both to the start of the list. Update each as follows:  \nwhile (pointer1) {  \npointer1 = pointer1->next;  \npointer2 = pointer2->next;  \nif (pointer2) pointer2=pointer 2->next; if (pointer1 = = pointer2) {  \nprint (\"circular\") ;}  \n}  \nVisit [http://TechPreparation.com](http://TechPreparation.com for more)[ for more](http://TechPreparation.com for more) Interview Questions with Answers Page 3  \nIf a list is circular, at some point pointer 2 will wrap around and be either at the item just before pointer 1, or the item before that. Either way, its either 1 or 2 jumps until they meet.  \n\"union\" Data Type What is the output ","cbCaip1EGz4bZEDj","https://ap.wps.com/l/cbCaip1EGz4bZEDj","pdf",130376,16,"English","# C Interview Questions and Answers\n## What is C language?\n## printf() Function\n## malloc() vs calloc()\n## printf(...) vs sprintf(...)\n## Compilation: reduce executable size\n## Linked Lists: detect circular lists\n## \"union\" Data Type\n## static variable meaning\n## Advantages of a macro over a function\n## Differences between malloc() and calloc()","[{\"question\":\"What is the difference between calloc(...) and malloc(...)?\",\"answer\":\"calloc(...) allocates memory for an array and initializes it to 0, while malloc(...) allocates a specified number of bytes without initializing the memory.\"},{\"question\":\"What happens when printf(\\\"%d\\\") is called with no matching argument?\",\"answer\":\"With only %d in the format string and no corresponding argument, the compiler accesses an expected value from the stack and prints whatever data happens to be at that memory location, leading to garbage output.\"},{\"question\":\"How can you check whether a linked list is circular?\",\"answer\":\"Use two pointers starting at the head, move one step for pointer1 and two steps for pointer2, and detect a meeting point indicating a cycle.\"}]","C Interview Questions and Answers - Interview Questions | PDF",1790358629]