Skip to main content

C Programming Interview Questions With Answers - Part I.


1. Explain Various Classes Of Datatypes Of C?

Answer: Following are the major classes of data types in C language:
  • Primary Data Types: Also, known as fundamental/basic data types. All C compilers support four basic data types namely: integer(int), character(char), floating(float), and double precision floating point (double). Then there are extended data types such as long int, double int.
  • Derived Data Types: Also, known as secondary or user-defined data types. These data types, derived from basic data types, include arrays, pointer, structure, union, enum etc.

2. What Are Escape Sequences Characters? List Any Six Of Them.

Answer: The characters which when used with output functions like printf( ), putc(), put() etc. helps in formatting the output are known as Escape sequence character. The following is a list of six escape sequences.
  • \n Newline
  • \t Horizontal Tab
  • \v Vertical Tab
  • \b Backspace
  • \r Carriage Return
  • \\ Backslash

3. What Do You Mean By Underflow & Overflow Of Data?

Answer: When the value of the variable is either too long or too small for the data type to hold, the problem of data overflow or underflow occurs. The largest value that a variable can hold depends on the machine. Since floating point values are rounded off to the number of significant digits allowed, an overflow results in the largest possible real value whereas an underflow results in zero.

C does not provide any warning or indication of integer overflow; it simply gives erroneous result.


4. List Any Six Commonly Found Programming Errors In A C Program.

Answer: Six commonly found errors in a C program are:
  • Missing or misplaced; or }, missing return type for a procedure, missing or duplicate variable declaration.
  • Type mismatch between actual and formal parameters, type mismatch on assignment.
  • Forgetting the precedence of operators, declaration of function parameters.
  • Output errors means the program runs but produces an incorrect result. This indicates an error in the meaning of the program.
  • Exceptions that include division by zero, null pointer and out of memory.
  • Non-termination means the program does not terminate as expected, but continues running "forever."

5. Explain Divide & Conquer Strategy To Solve Any Problem.

Answer: The original problem is solved by repeatedly solving a divided sub-problem that is of smaller size and can be solved more efficiently. The problem is split into smaller sub-problems recursively until we eventually reach a stage where sub-problem is small enough to break further and can be solved easily. This strategy is called Divide and Conquer strategy.


Suppose a problem P is associated with a set S and an algorithm partitions S into smaller sets such that solution of the problem P is reduced to solution of its smaller sub-sets. Then this algorithm is called divide and conquer algorithm. For example, in searching for a key in an ordered list, the size of the list is halved after every search.


6. Differentiate Between White Box & Black Box Testing.

Answer: White box testing strategy deals with the internal logic and structure of the code. White box testing also known as glass, structural, open box or clear box testing, tests code written, branches, paths, statements and internal logic of the code etc. To implement white box testing, the tester must deal with the code and hence is needed to possess knowledge of coding and logic i.e. internal working of the code. White box test also needs the tester to consider the code and find out which unit/statement/chunk of the code is malfunctioning.

White box testing is applicable at unit, integration and system level however it is mainly done at unit level.

Black box testing Black-box test design treats the system as a "black-box", so it doesn't explicitly use knowledge of the internal structure. It takes an external perspective of the test object to derive test cases. These tests can be functional or non-functional, though usually functional. The test designer selects valid and invalid input and determines the correct output. There is no knowledge of the test object's internal structure.

This method of test design is applicable to all levels of software testing: unit, integration, functional testing, system and acceptance.


7. A Program Has Been Compiled & Linked Successfully. When You Run This Program, You Face One Or More Of The Following Situations
    • Program Executed, But No Output
    • It Produces Incorrect Answers
    • It Does Not Stop Running.

What Are The Possible Causes In Each Case & What Steps Would You Take To Correct Them?

Answer: A program has been compiled and linked successfully.
  • Program executed, but no output: This usually happens due to run time errors in the program like referencing an out-of-range array element or mismatch of data types.
  • It produces incorrect answers: Then there may be logical errors in the program like failure to consider a particular condition or incorrect translation of the algorithm into the program or incorrect order of evaluation of statements etc.
  • It does not stop running: This happens when we make use of correct syntax statement but incorrect logic like if(code=1) count++; Instead of using comparison operator we are using assignment which is syntactically correct so count++ is always executed resulting in infinite loop. Similar mistakes may occur in other control statements, such as for and while loop that causes infinite loops and does not stop running.


Check Out Other Questions:

6) What is scope & storage allocation of extern and global variables?
7) What is scope & storage allocation of register?
8) What is scope & storage allocation of static and local variables?
9) What is the difference between 'break' and 'continue' statements?
10) What is the difference between uses of 'FOR' and 'WHILE' loops?


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?


...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...