C Interview Questions

5,472 c interview questions shared by candidates

1.write code that remove spaces from string and split it by ',' to array in O(n) 2.why the destructor should be Virtual (ans : to clean all the memory we created by sub class) 3.design 2 options of undo function for drawing page (ans : 1. faster but use more space - save each time the whole screen 2. less space but slower - save each time the last metadata of ecah object) 4.some probelm about not having copy cunstructor (use the default one - cause problem sometime - not allocate memory as we tought and might crash). 5.Factory pattern design. change from many "if" to factory design. (ans : Factory design and each time just add to dictionary and dont need to cahnge code)
avatar

C++ Developer

Interviewed at Algotec

4.1
Jan 8, 2019

1.write code that remove spaces from string and split it by ',' to array in O(n) 2.why the destructor should be Virtual (ans : to clean all the memory we created by sub class) 3.design 2 options of undo function for drawing page (ans : 1. faster but use more space - save each time the whole screen 2. less space but slower - save each time the last metadata of ecah object) 4.some probelm about not having copy cunstructor (use the default one - cause problem sometime - not allocate memory as we tought and might crash). 5.Factory pattern design. change from many "if" to factory design. (ans : Factory design and each time just add to dictionary and dont need to cahnge code)

For the first interview: similar questions to what other people wrote here with the addition of one new question: You are given a pseudo code for a paint program - the code creates buttons for the different shapes in the GUI and there is a function which is called when a button is pressed. This function draws the shape on the screen. You are asked to design the system/class structure in such a way that you are able to dynamically create the buttons (in a loop for instance) as well as adding support for new shapes with the addition of just one line of code (not including the code for drawing the shape) Second interview: You are given a system which is comprised of a DB table and XML Files. The system is built in such a way that for every record in the table there should be a corresponding XML file. Some of the fields in the record are present in the XML file, and there are some fields in the XML file which are not present in the DB. You are first tasked to explain how you would find the following 4 issues that may appear: 1) Missing XML: There are records which do not have a corresponding XML file 2) Orphaned XML: There are XML files which do not have a corresponding record in the table 3) Bad XML data: There are XML files with discrepancies with the DB (You do not know which is the good data and which is the bad data) 4) Corrupt XML data: There is an XML file which you cannot open The second question: Design an algorithm/work flow which will allow you to take the current state of the system and find out all the files/records with problems as stated above. Take into account that there are 10 million XML files and similar number of records The third question: Modify your algorithm to support fixing each problem encountered
avatar

Software Engineer (C++)

Interviewed at Algotec

4.1
Aug 31, 2016

For the first interview: similar questions to what other people wrote here with the addition of one new question: You are given a pseudo code for a paint program - the code creates buttons for the different shapes in the GUI and there is a function which is called when a button is pressed. This function draws the shape on the screen. You are asked to design the system/class structure in such a way that you are able to dynamically create the buttons (in a loop for instance) as well as adding support for new shapes with the addition of just one line of code (not including the code for drawing the shape) Second interview: You are given a system which is comprised of a DB table and XML Files. The system is built in such a way that for every record in the table there should be a corresponding XML file. Some of the fields in the record are present in the XML file, and there are some fields in the XML file which are not present in the DB. You are first tasked to explain how you would find the following 4 issues that may appear: 1) Missing XML: There are records which do not have a corresponding XML file 2) Orphaned XML: There are XML files which do not have a corresponding record in the table 3) Bad XML data: There are XML files with discrepancies with the DB (You do not know which is the good data and which is the bad data) 4) Corrupt XML data: There is an XML file which you cannot open The second question: Design an algorithm/work flow which will allow you to take the current state of the system and find out all the files/records with problems as stated above. Take into account that there are 10 million XML files and similar number of records The third question: Modify your algorithm to support fixing each problem encountered

Viewing 1291 - 1300 interview questions

Glassdoor has 5,472 interview questions and reports from C interviews. Prepare for your interview. Get hired. Love your job.