๐ง C Interview Questions
C is one of the most widely recognized general-purpose procedural computer programming language. It is one of the most fundamental skills today that we find in software engineers all over the world. We want to share with you the top C programming questions for freshers and experienced alike with a success story from New York. Enhanced with our own concepts, we hope you find this article helpful for your next C interview.

Data Types in C
C programming is important for the TCS Ninja exam. The questions can be based on data types. We have basic data type which is arithmetic type and which can be further classified into integer types and floating point types. We also have enumerated types which are arithmetic types and are used to define variables that can assign integer values throughout a C program. We also have a void data type. Void indicates that no value is available. One of the most important data types that the interview and assessment exams mostly focus on is derived data types. Derived data types include pointer, array, structure, union, and functions. Different integer types also occupy different storage sizes. For example, a char type occupies one byte whereas an integer occupies two or four bytes. I understood that it is important to remember the sizes of different types for the exam .The sizeof operator helps us to get the exact size of a type or a variable. A float type occupies a storage size of 4 bytes. A double type occupies our storage size of 8 bytes. A long double type occupies a storage size of 10 bytes. I wanted to make sure that I remembered each of these values for the main exam. I made a note of many such different storage sizes according to the data types and revised them frequently. I knew each of the details that I tried to memorize can help me score good marks in the exam.
Be TCS ready @ $1.3 per month.
๐ Did you know you can get $30 for sharing your exam and interview experiences? Write and get paid for every article. Learn more ยป
Pointers in C
Pointers in C are an important topic for the TCS Ninja exam. Pointers are extremely effective in certain tasks, but it cannot be used in all tasks like dynamic memory allocation where it is not efficient. Being good in pointers is definitely helpful to become a very good C programmer. Pointers hold the address of another variable. Pointers are themselves variables. Hence it is a variable that holds the address value of another variable. Pointers are denoted by the asterisk symbol. The usual value of a pointer is a long hexadecimal number. This number denotes a memory address. The questions in the TCS Ninja exam can revolve around best practices of using C pointers. I realized that a null pointer is important for the exam. So what is a null pointer? If I do not have the exact address to be assigned, it is a good practice to assign a null value to the pointer. This type of a pointer which is assigned null is called a null pointer. The concept of pointer seemed overwhelming to me initially. But as I continued to implement the pointer logics in various C programs, I gradually built up my confidence. I was not an expert in programming, so I needed a lot of practice to be able to solve complex programs in a limited amount of time. Being comfortable with pointers definitely gave me a lot of confidence in C programming related questions. I wanted to streamline and smoothen my rough edges in the most difficult topics in C programming.
Header Files in C
Header files are another important topic of C programming for the TCS Ninja exam. A header file has an extension of .h. We can use a header file to declare functions and define macros which can be shared between several source files. We can create two types of header files. One type of header file can be created by us, the programmer. The other type of header file comes with the compiler. We can use a header file in our program by including it with the C preprocessing directive include. Include basically tells a program to use the content of the header file. Using include is a good practice. Instead of copying the content of the header file into the program. This allows us to use the content of the header file in multiple programs without explicitly copying the content of the header file. If any changes is done in the header file, it will automatically be incorporated into the C programs that are using the header file. I practiced writing efficient programs and made sure that I always followed the best practices of C programming. I knew that good programming skill is essential to be a part of my dream organization. Efficient C programming also requires lesser lines of code. I wanted to optimize my coding skills so that I could incorporate maximum logic in the most simple way in the minimum number of lines. As I practiced more, I gradually improved my C programming skills.
Preprocessor in C
The C preprocessor is an important part of compilation in C programming. The preprocessor instructs the compiler to do preprocessing before the actual compilation takes place. The C preprocessor includes directives like define, include, undef, ifdef, etc. I tried to remember all the preprocessor Commons as many of these are important for a programmer. There are various ways to define the preprocessor directives. The only way to become comfortable with them was to keep using them in the various different C programs that I wrote. C also defines many macros. All of the macros are available for use in our programming. As a good practice, it is advisable not to directly modify the predefined macros. The C preprocessor provides various operators to help us create macros. For example, the stringize operator, token pasting operator, and defined operator are some of the operators provided by the C preprocessor. We can also parameterize macros in C++. With such a powerful tool in our hand, I felt that I should be able to implement and solve any complex algorithm provided. The only way to become a good programmer is to keep practicing with many programs. I kept practicing and continuously tried to optimize the programs that I wrote. I also prioritized the speed at which I wrote my programs. Often I felt that I was taking more than the optimal time to write some complex programs, but with more practice, gradually I kept improving my time. I wanted to be ready for the TCS Ninja exam.
Memory Management in C
Memory management in C programming is important for the TCS Ninja exam. We can use various functions for memory allocation and memory management. Some of them are calloc, free, malloc and realloc. We can also allocate memory dynamically in C programming. This is useful in such cases where we do not have an idea about how big of a content we’re going to deal with. This provides us with a lot of flexibility in memory control and management. I learned many good memory management practices. One of the most crucial memory management practices that the exam might often assess on is how to free the memory when it is not in active use. Even though the operating system automatically releases the memory that my program was using, it is a very good practice to specifically and explicitly release the memory in my program by using specific commands when the memory is not in use. To be a part of a great organization, it is not only crucial to have good programming skills, but also to adopt most of the best practices that great programmers advise on. I did not want to stay as an novice. I wanted to grow my skills. Hence I practiced a lot of programming using good memory management practices. I created my own memory exhaustive programs and tested their performance using various memory allocation scenarios. With this amount of hands-on experience, it gave me the confidence of being able to use the best practices of memory management in C programming.
File Operations in C
We can use C programming to create, open, close text or binary files. A file is considered as a sequence of bytes. I wanted to be ready with any kind of file related logic for the TCS Ninja exam. I started practicing the functions like fopen to create a new file and open an existing file. I started using the different functions available in the C Programming Standard library to process and handle different files. I also used various functions available to read and write a file character by character, or in the form of a fixed length string. I wrote programs to write to a file. I also wrote programs to read from a file. For the TCS Ninja programming questions I prepared myself to be able to handle binary input and binary output as well. Implementing file related logics was the only area that I found myself often struggling with. Since I was not a born expert programmer, I often struggled while implementing complex file processing logics. I realized that once I am comfortable in file handling, C programming seemed much more interesting. It was easy to forget many of the common functions, but with repeated use it became gradually simple to handle complex files. I was also able to handle complex logics regarding different types of files by using the different functions. I realized that there is no alternative to a lot of practice and so I made sure I kept on practicing.
Array in C
Arrays is an important data structure in C programming for the TCS Ninja exam. Arrays can store a collection of elements of the same type, which are sequential and of fixed size. The best thing I loved about arrays is that we did not need to declare many variables. Only by using one array we can store multiple values. It is also important to note that an array occupies contiguous memory locations. Another important characteristic that I learnt is that arrays can be multidimensional. This gives it a look and feel of a matrix. We can add a lot of flexibility if when accessing a multidimensional array, we use variables to define the positions of each element. Now by incrementing the values of the variables as per our need we can easily access each individual member of the array. I found it very interesting to note that we can add as many dimensions to an array we want. But when the number of dimensions is more than two, it usually becomes slightly difficult to handle and comprehend. I practiced a lot of C programs by using multidimensional arrays. Many of the programs that I wrote had more than three or even four dimensions. It was also interesting to update or insert new members in an array. I realized how flexible and powerful it made C programming. The effectiveness that came with this is very robust. Multidimensional arrays also have many practical use cases that we can use in real life scenarios.
Scope in C
It is important to have a clear idea of the scope of different values and variables in C programming. The scope is an interesting concept. For example, a variable does not exist beyond its scope. As a programmer, I found it very interesting because I can see the variable, but because it is not in scope we cannot access it. A variable can only be used by statements that are in the scope of that variable. Another kind of variable is a global variable. A global variable can hold their value throughout the entire program. We can use the same name for both local and global variables. But it is interesting to note that if we are using the same name, the local variable we refer inside a function will take preference. We can define a local variable by any of the common data types that we use. I learned that the default value of an int data type is 0. The default value of a pointer data type is null. I made sure that I practiced a lot of complicated scenarios, which uses both global and local variables. Only by implementing different use cases was it possible to get comfortable with these logics. The complexities might arise if we’re using the same variable both as local and global with the same name. Hence, it is important to be very careful and create our code strategically to avoid complex scenarios. I wanted to be a good programmer for the TCS Ninja exam and hence tried my best to master these concepts.
Operators in C
In C programming we have a variety of different operators that we use in our day to day life. The operator is specifically a symbol which instructs a compiler to perform a specific function. The function may be a mathematical function or a logical function. The important types of operators for the TCS Ninja exam are arithmetic, relational, logical, bitwise, assignment and miscellaneous. I found it very interesting how by using the increment operator we can construct a variety of complex logics in logical loops. The relational operators are also very important in C programming. The concepts of while loop is very interesting. We also have bitwise operators which work on bits and perform bit by bit operation. Another type of interesting operator that I came across is assignment operators which is extensively used in C programming. A miscellaneous type of operator is sizeof which returns the size of a variable. It is also important to remember the precedence of operators. I came across a variety of different categories of operators. I tried to use postfix, multiplicative, additive, and shift operators in my programs. I realized that the more I used my new concepts, the more I gained confidence. The bitwise operators are an interesting field of study that can be used in a variety of scenarios. I tried to complement my strong aptitude skills and created my own problems using C programming. I applied my own logic and tried to write the same program in a variety of different ways.
Structures in C
One of the most fascinating types of components that I came across is a structure. A structure is an user-defined data type that allows us to combine data items of different kinds. We used the struct statement to define a structure. We can create a combination of char and int elements using a structure. We can also combine other elements like float. For example, we can create a book structure. The elements inside it might be the title, the author and numeric book identifier. Now we can have multiple books, all of which are created by using the book structure. Each of them have their individual title, individual author name and unique book identifier. We can access the individual attribute of each book by using the member access operator, which is represented by a dot. Hence we have to mention the book variable name, and then the attribute, like the author. Another very interesting thing that I came across, which is important for the TCS Ninja exam, is that we can pass a structure as a function argument. We can also define a pointer to a structure. With structures, I realized that the limitations of C are only in our imagination. There seemed virtually nothing that we cannot achieve in C programming. I wanted to be able to implement most of the complex logics that I can be asked during the examination. So I practiced a lot to improve my skills and solve complex programs at a rapid pace.
๐ Did you know you can get $30 for sharing your exam and interview experiences? Write and get paid for every article. Learn more ยป
TCS Interview Questions
A uniquely continuously updated database of the latest TCS Interview questions.