Monday, April 2, 2012

C Interview questions and Answers | NEW Subjective Interview questions pdf

C Interview Questions Answers

Here are few examples of standard subjective oral questions asked in C interviews. Note how the questions are interrelated and how difficulty of questions increases as interview moves on. A mediocre student will perhaps give up after three or four questions and only those who have clear knowledge of concepts related to C language will make till the last question.

I recommend reading online forums, books like c loops and pitfall and experimentation with your code for clear knowledge of C concepts.

What is a data type?
It is means to identify type of data. When we are storing something in our program then we need to allocate some space for that purpose and while allocating that space we must also specify what kind of data is to be stored in the allocated space. Data types help to solve this problem.

Give example of some data types?
Int, char, float, void etc. are all examples of predefined basic primitive data types. Structures and Unions are user defined data types.

Is it possible to bring about conversion from one data type to other?
Yes, most programming languages provide ways for data to be converted from one data type to other. Data conversion can be both implicit and explicit. Implicit type conversion involves automatic type promotion. Explicit type conversion is also called type casting and may lead to loss in data precision.

What are strings and how can they be represented in c language?
Strings are collection of characters written in particular order. In ‘c’ language they can be implemented by either making array of characters or by making pointer to character data type.

Is there any difference between the two representations?
Often pointers and arrays are considered to be same in case of c language however there is a small difference in both. In case of pointers data is accessed indirectly, so you first retrieve the contents of the pointer, load that as an address (call it "L"), then retrieve its contents. If the pointer has a subscript [i] you instead retrieve the contents of the location 'i' units past "L". They are commonly used for dynamic data structures. In case of arrays Data is accessed directly, so for a[i] you simply retrieve the contents of the location i units past a. They are commonly used for holding a fixed number of elements of the same type of data.

Is it possible to convert strings in c/c++ to corresponding Integer?
atoi() is a predefined function whose prototype is declared in header file stdlib.h. It can be used to convert a string into corresponding integer value by passing the string as an argument in function.

What will happen if some illegal request is made to this function?
Function returns 0 if we try to convert any invalid string to integer. Eg. ‘aaa’ can’t be converted to an integer so atoi(‘aaa’); would return 0.

What will happen if any string in c is converted to integer explicitly?
If we try to convert string into integer explicitly then string’s address will get stored in integer.
int main(){
    char *a="abhas";
    int b=(int)a; // now b will hold address of a

C Interview Questions Answers PDF

All these questions are available as PDF at: 

No comments:

Post a Comment

Google+ Followers