Top 100 C Interview Questions and Answers

Updated 26 Jul 2025

Asked in TCS

2w ago

Q. What is a static variable in C? Can you provide an example program?

Ans.

A static variable in C is a variable that retains its value between function calls.

  • Static variables are declared using the 'static' keyword.

  • They are initialized only once, at the start of the program.

  • Their value persists even after the function call ...read more

Asked in NetApp

1w ago

Q. Can I declare a structure called 'a' which contains a structure called 'b', and 'b' in turn contains 'a'?

Ans.

Yes, it is possible to declare a structure 'a' that contains a structure 'b' and 'b' in turn contains 'a'.

  • To achieve this, we can use forward declaration of one of the structures.

  • By using a pointer or reference to the other structure inside the first...read more

Asked in Aptiv

1w ago

Q. What are the criteria for a C program?

Ans.

Criteria for C program include syntax correctness, logical flow, efficiency, and readability.

  • Correct syntax and logical flow are essential for program functionality

  • Efficiency is important for performance optimization

  • Readability ensures ease of mainte...read more

2w ago

Q. What is the difference between declaring an array int arr[5] and allocating memory using malloc(5 * sizeof(int))?

Ans.

The difference is that 'int arr[5]' creates an array on the stack, while 'malloc(5*sizeof(int))' allocates memory on the heap.

  • int arr[5] creates an array of 5 integers on the stack, which is a fixed-size memory allocation.

  • malloc(5*sizeof(int)) dynami...read more

Are these interview questions helpful?

Asked in Philips Innovation Campus and 2 others

2w ago

Q. How would you rate your C skills?

Ans.

I rate myself as proficient in C programming language.

  • I have extensive experience in writing C code for various projects.

  • I am familiar with the syntax and semantics of the language.

  • I have a good understanding of memory management and pointers in C.

  • I ...read more

Asked in TCS

2w ago

Q. Write a C program in Java.

Ans.

It is not possible to write a C program in Java as they are two different programming languages.

  • C and Java are different programming languages with different syntax and features.

  • C programs are written using C syntax and compiled with a C compiler.

  • Jav...read more

Share interview questions and help millions of jobseekers 🌟
man with laptop

Asked in Subex

2d ago

Q. Write code to retrieve a file in C.

Ans.

Code to retrieve a file in C

  • Use the fopen() function to open the file

  • Use the fread() function to read the contents of the file

  • Use the fclose() function to close the file

1w ago

Q. What is the maximum memory you can allocate with malloc()?

Ans.

The maximum memory that can be allocated with malloc() depends on the system's available memory and the size of the largest contiguous block of memory.

  • The maximum memory that can be allocated is limited by the system's available memory.

  • The size of th...read more

2w ago

Q. Explain all the storage classes in C.

Ans.

Storage classes in C define the scope and lifetime of variables.

  • auto: default storage class for local variables

  • register: stores variables in CPU registers for faster access

  • static: retains value between function calls

  • extern: used to access global vari...read more

Asked in XenonStack

2w ago

Q. Explain the C language in a way that a non-technical person can understand.

Ans.

C is a programming language used to create software and operating systems.

  • C is a low-level language that allows direct access to computer hardware.

  • It is used to create efficient and fast programs.

  • C is the foundation for many other programming languag...read more

C Jobs

Uber logo
Senior Marketplace Manager, Auto 4-9 years
Uber
4.2
Gurgaon / Gurugram
Uber logo
Senior Staff Engineer 14-16 years
Uber
4.2
Bangalore / Bengaluru
Uber logo
Sr Staff Engineer - L6 14-16 years
Uber
4.2
Bangalore / Bengaluru

Asked in Infosys

2w ago

Q. What are the latest advancements in embedded C programming?

Ans.

Latest embedded C programming includes features like dynamic memory allocation, multi-threading, and object-oriented programming.

  • Dynamic memory allocation allows for more efficient use of memory

  • Multi-threading enables concurrent execution of multiple...read more

Asked in Cisco

2w ago

Q. If you do not have a sizeof operator in C, how would you determine the size of an int?

Ans.

Use the sizeof operator on a variable of type int to get its size.

  • Use sizeof operator on a variable of type int

  • Size of int is typically 4 bytes

  • Size may vary depending on the system architecture

3d ago

Q. Implement memcpy in C.

Ans.

Implementing memcopy in C

  • Use a loop to copy each byte from the source to the destination

  • Handle overlapping memory regions correctly

  • Return a pointer to the destination

  • Ensure proper null termination for string copies

Asked in TCS

1w ago

Q. Explain a program written in C.

Ans.

A program in C is a set of instructions written in the C programming language to perform a specific task.

  • C programs are written using a combination of variables, data types, control structures, and functions.

  • They are compiled into machine code and ex...read more

Asked in Cognizant

2d ago

Q. Write a small C code.

Ans.

Write a small C code

  • Use the main function as the entry point of the program

  • Declare variables and assign values as needed

  • Use loops and conditionals to control the flow of the program

  • Utilize arrays and strings to store and manipulate data

  • Include necess...read more

Asked in Aptiv

1w ago

Q. What does the preprocessor do in C?

Ans.

Preprocessor in C is a tool that processes source code before compilation.

  • It performs macro substitution

  • It includes header files

  • It conditionally compiles code

  • It defines constants and symbols

  • It removes comments

  • Examples of preprocessor directives are #...read more

Asked in Jio

2w ago

Q. What is your experience with the C language?

Ans.

C language is a high-level programming language used for system programming and developing applications.

  • C is a compiled language

  • It is used for developing operating systems, device drivers, and other system software

  • C is also used for developing deskto...read more

2d ago

Q. To define file in Dynamic mode.

Ans.

Dynamic mode file is a file that is created and modified during runtime.

  • Dynamic mode files are created and modified during runtime

  • They are not stored on disk, but in memory

  • Examples include temporary files and buffers

Asked in Bosch

2w ago

Q. What is the difference between a null pointer and a void pointer?

Ans.

A null pointer points to nothing while a void pointer can point to any data type.

  • A null pointer is a pointer that has been explicitly set to a null value.

  • A void pointer is a pointer that has no type associated with it.

  • A null pointer is a subtype of a...read more

Asked in Atos

1w ago

Q. What are control statements in C?

Ans.

Control statements are used to control the flow of execution in a program.

  • There are three types of control statements in C: decision-making statements, loop statements, and jump statements.

  • Decision-making statements include if-else and switch stateme...read more

Asked in Exicom

1w ago

Q. Explain the difference between a structure and a union in C programming.

Ans.

Structure is a user-defined data type that groups related data members, while union is a data type that allows storing different data types in the same memory location.

  • Structures are used to group related data members of different data types, while u...read more

Asked in Qualcomm

2w ago

Q. What is a function pointer in C?

Ans.

A function pointer is a variable that stores the address of a function. Volatile type is used to declare variables that can be modified by external factors.

  • Function pointers are used to pass functions as arguments to other functions.

  • Volatile type is ...read more

Asked in Nvidia

1d ago
Q. What is the use of a function pointer in C?
Ans.

Function pointers in C are used to store the address of functions, allowing for dynamic function calls and callbacks.

  • Function pointers can be used to implement callbacks in event-driven programming.

  • They can be used to switch between different functio...read more

Asked in PayPal

3d ago

Q. How is memory allocation done in C?

Ans.

Memory allocation in C is done using functions like malloc, calloc, realloc and free.

  • malloc function is used to allocate a block of memory of specified size

  • calloc function is used to allocate a block of memory and initialize it to zero

  • realloc functio...read more

Asked in Wipro

2w ago

Q. Rate your C coding skills on a scale of 1 to 5.

Ans.

I would rate my C coding skills as 4 out of 5.

  • Proficient in writing efficient and clean C code

  • Experience in developing complex algorithms and data structures

  • Familiar with low-level programming and memory management

  • Able to debug and optimize code for ...read more

Asked in Straive

2d ago

Q. How do you invoke an XML file using LibXML?

Ans.

To invoke an XML file using LibXML, use the xmlReadFile() function.

  • Include the libxml/parser.h header file.

  • Use the xmlReadFile() function to read the XML file and create a xmlDocPtr object.

  • Use the xmlDocGetRootElement() function to get the root eleme...read more

Asked in Wipro

1d ago

Q. What comes to your mind when I tell you about the C language?

Ans.

C language is a popular programming language known for its efficiency and low-level programming capabilities.

  • C language is a general-purpose programming language.

  • It was developed by Dennis Ritchie at Bell Labs in the early 1970s.

  • C language is widely ...read more

Asked in NetApp

5d ago

Q. Implement strstr() Function in C Problem Statement

Given two strings A and B, find the index of the first occurrence of A in B. If A is not present in B, return -1.

Example:

Input:
A = "bc", B = "abcddbc"
Output:
1
Explanation:

Th...read more

Ans.

Implement the strstr() function in C to find the index of the first occurrence of one string in another.

  • Iterate through the main string and check if the substring matches at each position.

  • Return the index if a match is found, else return -1.

  • Handle ed...read more

Asked in Einfochips

2d ago

Q. Calculate the size of a variable without using a library function.

Ans.

Calculate size of variable without library function

  • Use the sizeof operator to calculate the size of a variable

  • Multiply the size by the number of elements if it's an array

  • Size of a struct is the sum of sizes of its members

  • Size of a union is the size o...read more

2d ago

Q. Write an API call in C.

Ans.

API call in C

  • Include the necessary header files

  • Create a URL string with the required parameters

  • Use the curl library to make the API call

  • Handle the response data appropriately

Previous
1
2
3
4
5
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
Tech Mahindra Logo
3.5
 • 4.2k Interviews
HCLTech Logo
3.5
 • 4.2k Interviews
Cisco Logo
4.2
 • 387 Interviews
View all
Interview Tips & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
C Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 Lakh+

Reviews

10L+

Interviews

4 Crore+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits