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

What Is (Are) Your Weakness (Weaknesses)? - Interview Answers

There’s a saying – “However small the thorn maybe it has the ability to pierce.” Never say you are a Workaholic, a Perfectionist, etc. because it sounds negative. Try to convert these negative biased qualities into positive ones. For Example, In   place of Workaholic you can say you are a hard worker and always willing to work for extra hours. In place of Perfectionist , you can say you are detail oriented and like to set high standard for work. “Try to specify your weakness as your strength and also highlight it as a benefit.” Your answers can be: 1) One of my weaknesses as I perceive is occasional compromise on time for quality and perfection. 2) I feel I am not very detail-oriented . I’m a person that wants accomplish as much as possible. I realized this hurts quality and therefore I‘m trying hard to find a balance between quality and quantity. 3) At times even when I need help, I try to solve my own problems instead of asking a co-worker who might know...

What Is (Are) Your Strengths? - Interview Answers

This is a simple and popular interview question. Generally people answer it in two ways. There are people who simply state their strength like “I am Young, Dynamic, Intelligent, Smart and so on…”. Such answer is neither right nor wrong but does not help u in any way also. Secondly there are peoples who state their strengths and explain them how he can use his strength for the job and industry. Do not simply state your strength. Everyone has some strength, all you need is to convert them into benefits. In short, try to advertise yourself by converting your features into strengths. “EVERYONE CLAIM THEY ARE HONEST, HARDWORKING, SMART AND SO ON….. BUT WITH AN EXAMPLE IT IS MUCH MORE BELIEVABLE.” Your answers can be : 1) I am a hard worker and because of this ability I can work for additional hours to accomplish my tasks.I am commitment oriented and hence I always enjoy the trust and confidence of my team mates which enables me to perform my duties very easily. 2) I am a...