Tata Consultancy Services
Sample Interview Questions in
Sample Interview Questions in
C Programming Language
Below are few basic questions that can be expected on TCS interviews. These are not hard to answer but a good preparation is necessary so that you don't miss any.
Question 1 : What is the prime difference between While and Do While Loop ? Answer : Though while and do-while are loop statements, in Do While it is assured that the statements within the loop will be executed at least once (even if the condition fails.) Interview Question 2 : What is the difference between a = ++b and a = b++ ?
Answer : The first statement a = ++b can be broken down into two statements b = b + 1 followed by a = b. Hence b will be incremented first and will be assigned to a. Hence values of a and b will be same at the end. The second statement a = b++ can be broken down into two statements a = b followed by b = b + 1. Hence b will be assigned to a. Only after this assignment b will be incremented. Hence values of a and b will be different at the end. Interview Question 3 : A C program is compiled into native (binary) code by the compiler. Similarly what will be generated out of JAVA program source by JAVA compiler ?
Answer : JAVA program will get compiled into bytecode instead of native (binary) code. Interview Question 4 : Practice Question For Your Thought :
Given a for statement for(i = 1;i < 10;i++) { printf("hello"); } Now you can try by yourself rewriting the same logic using while statement. Using While Loop i=1; while (i++<10) printf("hello"); Interview Question 5 : Which of the following program structure/component/statement is not an example for implementation of modularization ?
Options : a) DLL b) Functions c) type casting Answer : Option c) type casting. DLL and Functions help in modularization of a program while typecasting just converts from one data type to another. Interview Question 6 : Can a program be invoked from another program ? If yes, how it can be done ?
Answer : Yes, a program can invoke another program using system calls. Interview Question 7 : Most of you would be knowing "Register" variables are the ones stored in CPU for faster access. Is there a crude way to determine data size for register variables.
Answer : Yes, generally the size would be less than or equal to integer data size. There are exceptions too. Interview Question 8 : Is it necessary to use register modifier on all compilers irrespective of whether they are old or modern ones ?
Answer : No, compilers nowadays are intelligent enough to decide which variables need to be kept in CPU registers depending upon the estimated usage. Interview Question 9: What is a data type?
Answer: Int, char, float, void etc. are all examples of predefined basic primitive data types. Structures and Unions are user defined data types. Interview Question 10:: 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. Interview Question 11:: Is it possible to bring about conversion from one data type to other?
Answer: 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. Interview Question 12:: What are strings and how can they be represented in c language?
Answer: 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. Interview Question 13: Is it possible to convert strings in c/c++ to corresponding Integer?
Answer: 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. Interview Question 14: What will happen if any string in c is converted to integer explicitly?
Answer: 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 } Interview Question 15: 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. |
Chennai Address: Siruseri Special Economic Zone,
Plot No. 1/G1, SIPCOT Information Technology Park Navalur Post, Siruseri - 603 103, Tamil Nadu, India Phone: +91 44 67422222 Fax: +91 44 67422223 Office Type: Delivery Center Chennai Address:Tata Consultancy Services
Digital Zone, No. 79, IT Highway Karapakkam, Chennai 600096 Phone: +91 44 66163333 Fax: +91 44 6616 3435 Office Type: Delivery Center Center of Excellence Innovation Lab Regional Office |
Chennai Address:Tata Consultancy Services
165/1A, Velachery - Taramani 100 Feet Road, Velachery, Chennai - 600042 Phone: +91 44 66166999 Fax: +91 44 66167070 Office Type: Delivery Center Innovation Lab Regional Office Description: TCS Innovation Labs - Chennai Chennai Address:Tata Consultancy Services
No. 1, Habibullah Road, T Nagar, Chennai 600 017 Phone: +91 44 66164999Fax: +91 44 66164998 Office Type: Regional Office |