Top C Programming Interview Questions & Answers. last updated March .. The basic data types are int, char, and float. . Download PDF. C programming language was developed at Bell Laboratories in by Dennis Ritchie. C is structure/procedure oriented programming language whereas C++ is object oriented programming language. Polymorphism, virtual function, inheritance, Operator overloading, namespace concepts are. Frequently asked C interview questions with answers and detailed explanations for technical interviews in pdf. Download PDF to practice.

Basic C Interview Questions And Answers Pdf

Language:English, Dutch, German
Published (Last):19.02.2016
ePub File Size:22.83 MB
PDF File Size:13.12 MB
Distribution:Free* [*Sign up for free]
Uploaded by: SIBYL

The C programming language is a standardized programming language Visit for more Interview Questions with Answers. Page 2. Look for Basic C jobs interview questions and answers page and understand the interview model to prepare in a strategic way so as to get best results in return. C is the general and basic programming language that will create a base for other programming languages. Read Top C programming interview questions and answers. Download C programming interview questions PDF.

C questions and answers

C is the general and basic programming language that will create a base for other programming languages. C programming language was designed by Dennis Ritchie in Bells Lab. And it appeared around 46 years ago that is in and it was stably established on 11 December It is a crucial language of computer and it is coded in assembly language and it can run on from supercomputers to the embedded systems. Flag values are used to make decisions between two or more options during the execution of a program.

Generally, flag values are small often two and it tries to save space by not storing each flag according to its own data type. The best way to store flag values is to keep each of the values in their own integer variable.

If there are large number of flags, we can create an array of characters or integers. We can also store flag values by using low-order bits more efficiently.

Bit fields are used to store multiple, logical, neighboring bits, where each of the sets of bits and single bits can be addressed.

Bit masking refers to selecting a particular set of bits from the byte s having many values of bits. Bit masking is used to examine the bit values and can be done by 'AND' operation of byte, bitwise.

Call by value: A process in which the values of the actual parameters sent by the calling function are copied to the formal parameters of the called function. Call by reference: A process in which the parameters of a calling function are passed to the parameters of the called function using an address. C language allows the use of the prefix register in primitive variable declarations.

Such variables are called register variables and are stored in the registers of the microprocessor. The number of variables which can be declared register are limited.

If more variables are declared register variables, they are treated as auto variables.

A program that uses register variables executes faster as compared to a similar program without register variables. It is possible to find out the allocation of register variables only by executing and comparing the performance with respect to the time taken by the program perceptible in large programs.

It is the responsibility of the compiler to allow register variables. In case the compiler is unable to do so, these variables are treated as auto variables. Loop indices, accessed more frequently, can be declared as register variables.

It also means that the value of the variable persists between successive calls to a function. The value of such a variable will remain and may be seen even after calls to a function. One more thing is that a declaration statement of such a variable inside a function will be executed only once. Question 6. The following are the differences between structures and arrays: Question 7. Define Macros. A macro is a name given to a block of C statements as a pre-processor directive. Being a pre-processor, the block of code is communicated to the compiler before entering into the actual coding main function.

A macro is defined with the preprocessor directive, define.

The advantage of using macro is the execution speed of the program fragment. When the actual code snippet is to be used, it can be substituted by the name of the macro. The same block of statements, on the other hand, need to be repeatedly hard coded as and when required. The disadvantage of the macro is the size of the program.

The reason is, the pre-processor will replace all the macros in the program by its real definition prior to the compilation process of the program.

Question 8. This value is passed as a constant or a variable with value. The function can update the value available in the memory location by referencing the pointer. Question 9. Define Static Identifier In C?

This value can be used between function calls. The default value of an uninitialized static variable is zero. A function can also be defined as a static function, which has the same scope of the static variable. Question What Are The Auto Variables? Where Are They Stored? The auto variables are stored in the main memory of the system.

The keyword 'auto' is optional. Many of the variables used by the program or application are 'auto' variables, being the main memory is faster.

These variables are stored in the memory runtime stack. It is de-allocated at the completion of its block execution. It is a local variable which is allocated and deallocated automatically when the program flow enters and leaves the variable's scope.

The difference between arrays and linked lists are: A set of named integer constants is known as an enumeration. The enumeration type declaration includes the name of the enumeration tag and the definition of a set of named integers.

Variables of enumeration type persists one of the existing values of the enumeration set. The enum type variables could be utilized in indexing expressions, as operands of all arithmetic and relational operators. ANSI C enum expressions are always have int type, which occupies the memory space that occupied by the int type.

The identifier sunday is explicitly assigned with 0. The remaining identifiers are given values 1 through 5 by default. The scope of a variable is specified by its storage allocation. This is specified by the keywords — auto, extern, static and register.

The keyword typedef is used for defining user defined data types. A new definition of existing data types is created by using typedef. It is used to define user defined identifiers which can be used in substitution of type specifiers such as int, float etc. It does not reserve memory space. The names defined by typedef are synonyms for the data types.

If Possible How? The fgets function is safer to use. It checks the bounds, i. The gets function does not check the bounds. The gets function is an insecure and careless use can lead to errors. The function strcpy will not allocate the memory space to copy.

A pointer to the string to copy and a pointer to place to copy it to should be given.

This memory space needs to be freed up later when it is of no use anymore. For char[] array, such size is not accepted by the compiler. Define Void Pointer? A void pointer is pointer which has no specified data type. It is also known as a generic pointer. The void pointer can be pointed to any type. If needed, the type can be cast.

A void pointer is generally used as function parameters, when the parameter or return type is unknown. What Is A Const Pointer? A const pointer is not the pointer to constant, it is the constant. In the above example it is not, Hence it is not the pointer to constant. The ptr can not be used to point to another integer.

C Programming Interview Questions

The integer pointed by ptr can be changed. The const pointer can not be changed to point to other memory location, because the pointer is constant. Explain Memory Leak? An unwanted increase in programs is referred to as a memory leak is C language.

The intake of the program increases in the memory by an unintentional consumption of the memory. If the program is getting corrupted and results in errors, it means the memory leak. OBJ object file, and an executable. EXE file.

Reserved words are words that are part of the standard C language library. This means that reserved words have special meaning and therefore cannot be used for purposes other than Explain What it is originally intended for. Examples of reserved words are int, void, and return.

A linked list is composed of nodes that are connected with another.

In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage. Binary trees are actually an extension of the concept of linked lists. A binary tree has two pointers, a left one and a right one. Each side can further branch to form additional nodes, Explain Which each node having two pointers as well.

All reserved words must be written in lowercase; otherwise the C compiler would interpret this as unidentified and invalid. You cannot use reserved words as a user-defined variable. One may think that INT is a reserved word and must not be used for other purposes. Explain However, recall that reserved words are express in lowercase, so the C compiler will not interpret this as a reserved word. This is used to insert a new line when displaying data in the output screen.

A newline escape sequence can be placed before the actual output expression or after. It is the process of transferring data to an alternative output source other than the display screen. Output redirection allows a program to have its output saved to a file. These 2 functions basically perform the same action, Explain Which is to get the absolute value of the given value. Abs is used for integer values, while fabs is used for floating type numbers.

Also, the prototype for abs is under , while fabs is under. It is used to convert any letter to its upper case mode. Toupper function prototype is declared in.

Note that this function will only convert a single character, and not an entire string. The strcat function. It takes two parameters, the source string and the string value to be appended to the source string. Yes, they both do the exact same thing, Explain Which is to accept the next key pressed by the user and assign it to variable named letter. Text files contain data that can easily be understood by humans.

It includes letters, numbers and other characters. On the other hand, binary files contain 1s and 0s that only computers can interpret. Yes, it is possible to create a customized header file.

Just include in it the function prototypes that you want to use in your program, and use the include directive followed by the name of your header file. Dynamic data structure provides a means for storing data more efficiently into memory.

Using dynamic memory allocation, your program will access memory spaces as needed. This is in contrast to static data structure, wherein the programmer has to indicate a fix number of memory space to be used in the program.

Explain How would you place this character as part of the output on the screen? For example, you can write printf? Storing data on the heap is slower than it would take when using the stack. Explain However, the main advantage of using the heap is its flexibility. Slowness in the heap can be compensated if an algorithm was well designed and implemented.

Preprocessor directives are placed at the beginning of every C program.

This is where library files are specified, Explain Which would depend on Explain What functions are to be used in the program.

Another use of preprocessor directives is the declaration of constants. Preprocessor directives begin with the symbol. Just the same, s! Order of precedence determines Explain Which operation must first take place in an operation statement or conditional statement. On the top most level of precedence are the unary operators! This is because C language is rich in features that make it behave like a high level language while at the same time can interact with hardware using low level methods.

The use of a well structured approach to programming, coupled with English-like words used in functions, makes it act as a high level language. On the other hand, C can directly access memory structures similar to assembly language routines.

In C programming, there is a data structure known as queue. A queue represents a line wherein the first data that was stored will be the first one that is accessible as well. In the first expression, the increment would happen first on variable a, and the resulting value will be the one to be used.

This is also known as a prefix increment. In the second expression, the current value of variable a would the one to be used in an operation, before the value of a itself is incremented. This is also known as postfix increment.

C language is a case sensitive language. An endless loop can mean two things. One is that it was designed to loop continuously until the condition within the loop is met, after Explain Which a break function would cause the program to step out of the loop.

Job Interview Questions & Answers

Another idea of an endless loop is when an incorrect loop condition was written, causing the loop to run erroneously forever.Pointers point to specific areas in the memory. Explain However, some programmers prefer declaring the structure globally, then pass a variable of that structure type to a function. C language is belonging to middle level language. Anonymous says: What is the difference between single and compound statements in C?

An allocation or deallocation of memory is done at the execution time of a program. Double — Double-precision floating point value Char — Single character Void — Special purpose type without any value. For example: int a[10]; The above example creates an array of integer type, and the size of an array is fixed, i. It is the responsibility of the compiler to allow register variables. Where does global, static, and local, register