Interview questions and answers for C language

Jan 10 • Resources • 37072 Views • 55 Comments on Interview questions and answers for C language

List of Interview questions and answers for C language : 

The C programming language is mother of all programming languages. It is very simple and easy to learn.In interview there are lots of question asked from this domain so prepration of the topic is very much important.We have prepared a list of 10 questions which is very important and can be asked in any interview.

1. What is C Language ?

Ans – C is a general purpose programming language and it was developed by Dennis Ritchie. Programs written in this language are the set of instructions given by a programmner to the computer in high level language. The program execution process consists of two processes , first   it uses a compiler to translate the high level program into machine code then execute the instruction set.

interview question on c

Important c questions

2. What does static variable mean ?

Ans – Static variable is available to a C application, throughout the life time of the program. At the time of starting the program execution, static variables allocations takes place first. In a scenario where one variable is to be used by all the functions (which is accessed by main () function), then the variable need to be declared as static in a C program.

3. What is the difference between calloc() and malloc() ?

Ans – A block of memory may be allocated using the function malloc malloc(). The malloc function reserves a block of memory of specified size and returns a pointer of type void(). This means we can assign the base address of the block to any type of pointer

                                      Syntax –     P = (cast type*)malloc(byte size);

Calloc() is also a memory allocation function which is generally used to allocate memory for array and structure. malloc() is used to allocate a single block of storage space, calloc() allocates multiple blocks of storage, each of same size and initializes them with zero.

                                      Syntax –     P = (cast type*)calloc(n,array size);

4. What is a NULL pointer ?

Ans – A NULL pointer is a pointer which is pointing to nothing. It just points the base address of the segment. It means that it will not point to  other valid pointer, other variable, array cell or anything else. It will never be compared with anything.

Example :

  1. Integer pointer : int *ptr=(char *);
  2. Float Pointer : float *ptr=(float *);
  3. Character Pointer : char *ptr=(char *);

5. Advantages of a macro over a function ?

Ans – Actually macro and function are used for different purposes. A macro replaces its expression code physically in the code at the time of preprocessing. But in case of function the control goes to the function while executing the code. So when the code is small then it is better to use macro.But when code is large then function should be used.

6. What is page thrashing ?

Ans – It happens when a high level of paging activity happen. Thrashing is caused by under allocation of minimum number of pages required by a process, forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming. This problem can be eliminated by reducing the level of multiprogramming.

7. How do you override a defined macro?

Ans – You can use the #undef preprocessor directive to undefine (override) a previously defined macro. A way of overriding  macro is shown below.
#ifdef MACRO
#undef MACRO
#endif
#define MACRO X

8. What are the different storage classes in C ?

Ans – C has three types of storage classes: automatic, static and allocated.

  1. Variable having block scope and without static specifier have automatic storage duration.
  2. Variables with block scope, and with static specifier have static scope.
  3. Global variables (i.e, file scope) with or without the static specifier also have static scope.Memory obtained from calls to malloc(), alloc() or realloc() belongs to storage class.

9. When does the compiler not implicitly generate the address of the first element of an array?

Ans – Whenever an array name appears in an expression such as

  • array as an operand of the sizeof operator.
  • array as an operand of “&” operator.
  • array as a string literal initializer for a character array.

Then the compiler does not implicitly generate the address of the address of the first element of an array.

10. Is using exit() the same as using return ?

Ans – No, The exit() function is used to exit from your program and return control to the operating system. The return statement is used to return from a function and return control to the calling function. If you issue a return from the main() function, you are essentially returning control to the calling function, which is the operating system. In this case, the return statement and exit() function are similar.

For any feedback / query please leave  a comment.

You may also like to go through :

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

55 Responses to Interview questions and answers for C language

  1. A. Preethi says:

    B. Tech first year

  2. A. Preethi says:
  3. Anonymous says:
  4. eeeee says:

    Cprogeam

  5. PRADEEP YADAV says:

    IMPOTANT QUESTION FOR C LANGUAGE IN O LEVEL EXAM,IPOTANT TOPIC ALSO

  6. PRADEEP YADAV says:

    IMPOTANT QUESTION FOR C LANGUAGE IN O LEVEL EXAM,IPOTANT TOPIC ALSO

  7. PRADEEP YADAV says:

    IMPOTANT QUESTION FOR C LANGUAGE IN O LEVEL EXAM,IPOTANT TOPIC ALSO

  8. PRADEEP YADAV says:

    IMPOTANT QUESTION FOR C LANGUAGE IN O LEVEL EXAM,IPOTANT TOPIC ALSO

  9. PRADEEP YADAV says:

    IMPOTANT QUESTION FOR C LANGUAGE IN O LEVEL EXAM,IPOTANT TOPIC ALSO

  10. PRADEEP YADAV says:
  11. parwinder says:

    12 and continue diploma

  12. parwinder says:

    12 and continue diploma

  13. Anonymous says:
  14. Anonymous says:
  15. Anonymous says:
  16. Vinith says:

    No

  17. Ravibhushan dubey says:

    Study about C language

  18. Ravibhushan dubey says:

    Study about C language

  19. Ravibhushan dubey says:

    Study about C language

  20. Ravibhushan dubey says:

    Study about C language

  21. Ravibhushan dubey says:

    Study about C language

  22. zakeer says:

    b.tech 1st year

  23. zakeer says:

    b.tech 1st year

  24. zakeer says:

    b.tech 1st year

  25. susi says:
  26. susi says:
  27. Bhuwan Magar says:

    Reading class 12

  28. Bhuwan Magar says:

    Reading class 12

  29. Bhuwan Magar says:
  30. C. Sireesha says:

    Sree sai masterminds degree College

  31. C. Sireesha says:

    Sree sai masterminds degree College

  32. C. Sireesha says:
  33. Vino says:

    Bsc cs

  34. Abdul Shakeem says:

    just for learning

  35. Abdul Shakeem says:

    just for learning

  36. Abdul Shakeem says:

    just for learning

  37. Abdul Shakeem says:

    just for learning

  38. Abdul Shakeem says:

    just for learning

  39. Abdul Shakeem says:

    just for learning

  40. Abdul Shakeem says:
  41. Abdul Shakeem says:
  42. Sivathulasi Penigalapati says:

    Important question in c language

  43. Savita shukla says:

    No

  44. Savita shukla says:
  45. SBI says:

    difference between arrays,pointers ,structures?
    define macro?
    what is type casting?
    what is auto storage class?

  46. ganesh says:

    Chapter wise important questions for DECE students

  47. Ashish Kumar Pal says:

    i want to some note c language for a competitve exam .

  48. Atul Kumar Shukla says:

    The c language is the basic and fundamental language.The logic of c language used for developing any plateform or any softwere.
    are u think that scope of this language will be end????????????

  49. Jagriti Singh says:

    Useful post for all who belongs to software fields..must give a look on this

  50. saurabh jajoo says:

    that is an awesome try to get a new one close to c language….great

  51. ayushi says:

    a great help to those who are preparing for campus recruitment..

  52. sakshi chaudhary says:

    C language is mainly the basic requirement for most of the job interview profile and if someone is preparing for it, should take help from the post as it contains all the needy stuff that are required for the preparation…

  53. saurabh singh says:

    I think this post is really helpful for those who want to crack interview and want to make their career in the field of software..

  54. BHARTI PANDEY says:

    C LANGUAGE most necessary for JOBS INTERVIEW…..This POST provides me with some of the Basic INFO about C LANGUAGE….It would be a great help if the author provides more of these….

« »