Skip to main content

C Programming Interview Questions With Answers - Part II.


8. State The Differences Between Program Testing & Debugging.

Answer: Program Testing is the process of checking program, to verify that it satisfies its requirements and to detect errors. These errors can be of any type - Syntax errors, Run-time errors, Logical errors and Latent errors. Testing include necessary steps to detect all possible errors in the program. This can be done either at a module level known as unit testing or at program level known as integration testing.

Debugging is a methodical process of finding and reducing the number of bugs in a computer program making it behave as expected. One simple way to find the location of the error is to use print statement to display the values of the variables. Once the location of the error is found, the error is corrected and debugging statement may be removed.


9. State The Differences Between Top down & Bottom Up Approaches?

Answer: A top-down approach is essentially breaking down a system to gain insight into its compositional sub-systems. In a top-down approach an overview of the system is first formulated, specifying but not detailing any first-level subsystems. Each subsystem is then refined in greater detail, sometimes in many additional subsystem levels, until the entire specification is reduced to base elements. In short the top down approach means decomposing of the solution procedure into subtasks. This approach produces a readable and modular code that can be easily understood and maintained.

A bottom-up approach is essentially piecing together systems to give rise to grander systems, thus making the original systems sub-systems of the emergent system. In a bottom-up approach the individual base elements of the system are first specified in great detail. These elements are then linked together to form larger subsystems, which then in turn are linked, sometimes in many levels, until a complete top-level system is formed.


10. State The Differences Between Interpreted & Compiled Languages?

Answer: In interpreted languages, the instructions are executed immediately after parsing. Both tasks are performed by the interpreter. The code is saved in the same format that we entered. Interpreted languages include the MS-DOS Batch language (the OS itself is the interpreter), shell scripts in Unix/Linux systems, Java, Perl etc.

Advantages of interpreted languages include relative ease of programming and no linker requirement. Disadvantages include poor speed performance and that we do not generate an executable (and therefore distributable) program. The interpreter must be present on a system to run the program.

In compiled languages, the instructions into machine code and store them in a separate file for later execution. Many modern compilers can compile (parse) and execute in memory, giving the 'appearance' of an interpreted language.

However, the key difference is that parsing and execution occurs in two distinct steps. Examples of compiled languages include Visual Basic, C/C++, Delphi and many others. In a compiled environment, we have several separate files like: source code (the text instructions), object code (the parsed source code) and the executable (the linked object code).

There is definitely an increase in complexity in using compilers, but the key advantages are speed performance and that one can distribute stand-alone executables.


11. Briefly Explain What Do You Understand By Stepwise Refinement Of The Program?

Answer: The concept of "Stepwise Refinement" means to take an object and move it from a general perspective to a precise level of detail and this cannot be done in one jump but in steps. The number of steps needed to decompose an object into sufficient detail is ultimately based on the inherent nature of the object. "Stepwise Refinement" of program represents a "divide and conquer" approach to design.

In simple words, break a complex program into smaller, more manageable modules that can be reviewed and inspected before moving to the next level of detail. Stepwise refinement is a powerful paradigm for developing a complex program from a simple program by adding features incrementally.

Some of the steps taken for refinement of a program are:
  • Analysis of the algorithm used to develop the program, and analysis of various parts of the program and then making appropriate changes to improve the efficiency of the program.
  • Keep the program simple to improve memory efficiency.
  • Evaluation and incorporation of memory compression features.
  • Debugging and testing performed first to module level and then to interface level.
  • Take care of correct working and clarity while making it faster.


12. What Is The Difference Between Declaring A Variable & Defining A Variable?

Answer: The difference between declaring a variable and defining a variable is that while declaring a variable, the compiler verifies if the variable has been defined elsewhere but does not allocate memory for that variable. It is a kind of explicit declaration of a variable.

But while defining a variable, the compiler allocates specific memory for the variable and initializes the variable to some value. Normally, variables are declared after defining.


13. What Is Looping?

Answer: Loop is a control structure used to perform repetitive operation. Some programs involve repeating a set of instruction either a specified number of times or until a particular condition is met. This is done using a loop control structure. A program loop consists of two parts: Body of the loop and control statement. The control statement tests certain conditions and then decides repeated execution or termination of statements. Most real programs contain some construct that loops within the program, performing repetitive actions on a stream of data or a region of memory.


14. How Would You Distinguish Between Looping/Iteration & Recursion?

Answer: Some of the points that distinguish between recursion and looping/iteration are:
  • Recursive function is a function that is partially defined by itself whereas Iterative Instructions are loop based repetitions of a process.
  • Recursion Uses selection structure Iteration uses repetition structure Infinite recursion occurs if the recursion step does not reduce the problem in a manner that converges on some condition whereas an infinite loop occurs with iteration or looping if the loop-condition test never becomes false.
  • Recursion terminates when a base case is recognized whereas Iteration/looping terminates when the loop condition fails.
  • Recursion is usually slower then iteration/looping due to overhead of maintaining stack whereas Iteration/looping does not use stack so it's faster than recursion.
  • Recursion uses more memory than iteration/looping.
  • Infinite recursion can crash the system whereas infinite looping uses CPU cycles repeatedly.
  • Recursion makes code smaller whereas Iteration makes code longer.


Check Out Other Questions:

11) Which bitwise operator is used for checking whether a particular bit is ON or OFF?
12) Which bitwise operator is used for turning OFF a particular bit in a number?
13) What is equivalent of multiplying an unsigned int by 2: left shift of number by 1 or right shift of number by 1?
14) What is Enumeration?
15) What is a structure?


16) What are the differences between a structure and a union?
17) What is meant by union?
18) What are the advantages of unions?
19) How can typedef be used to define a type of structure?
20) What is enumeration constant?


...Return To C Questions INDEX.

...Return To C Programming INDEX.


... Return To HR Interview Index

Comments

Popular posts from this blog

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview . That's why this statement is often called the "Positioning Statement". One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly. YOUR ANSWERS CAN BE: 1) I am a person with strong interpersonal skills and have the ability to get along well with people . I enjoy challenges and looking for creative solutions to problems. 2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies apti...

HR Interview Questions With Simple Answers - Top 30.

Here are some very important HR questions which are often asked during Interviews and I believe these answers can really help you to get through....... Click on them to view the answer: 1) Tell Me Something About Yourself ? 2) What Are Your Strengths? 3) What Are Your Weaknesses? 4) How Do You Handle Pressure / Can You Work Well Under Pressure? 5) What Are Your Short Term Goals? 6) What Are Your Long Term Goals? 7) Where Do You See After 5 Years? 8) Why Should We Hire You? 9) What Is Your Salary Expectation? 10) Why Do You Want To Leave Your Current Job? 11) Do You Prefer To Work Alone Or As A Team Player? 12) What Made You Choose Your Major / Stream? 13) Why Didn’t You Pursue A Career In Your Major / Stream? 14) Why Do You Want To Work For Us? 15) Are You Willing To Travel? 16) Are You Willing To Take Risks? 17) What Do You Know About This Company? 18) What Do You Seek From A Job? 19) How Do You Evaluate Success? 20) Dur...

Sample Cover Letter / Job Application.

To The General Manager (HR) [ Name and Designation (Bold Words)] Infosys Limited Delhi – 110001 Uttam Agrawal Gandhi Chowk, Bhartee Street [ Name Bhawanipatna, Kalahandi Contact Address Orissa – 766001 Telephone No.] Ph. no - +91-9438170446 [Sub: Application for the position of ___________ in your esteemed organization.] Respected Sir, (Always use ‘Respected’) With reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ___________ . I would like to place myself as a strong contender before you. OR This has reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ____________. In the said connection I take this opportunity to apply for the said position as a strong contender. /*This is the Introduction i.e the first paragraph of your application/* ( Now the Second Paragraph is the Self Introduction) Try to start the second paragraph with the below mentioned lines: - I have the p...