Top 100 C Interview Questions and Answers

Updated 25 Jul 2025

Asked in Accenture

3d ago

Q. Write code to find the length of a string without using the strlen() function.

Ans.

Code to find length of string without using strlen() function.

  • Use a loop to iterate through each character of the string

  • Increment a counter variable for each character in the string

  • Stop the loop when the null character '\0' is encountered

  • Return the c...read more

Asked in TCS

2d ago

Q. What is C code in Java?

Ans.

C code in Java refers to the use of the Java Native Interface (JNI) to incorporate C code into Java programs.

  • C code in Java is typically used when performance optimization or low-level system access is required.

  • JNI allows Java programs to call C func...read more

Asked in Wipro

1d ago

Q. Draw the flowchart for the following C program.

Ans.

Flow chart for a C program

  • Identify the input and output

  • Determine the conditions and loops

  • Draw the flow chart accordingly

5d ago

Q. How can we do web development using C?

Ans.

Web development using C involves using frameworks like CGI, FastCGI, or libraries like libmicrohttpd.

  • Use frameworks like CGI or FastCGI to handle HTTP requests and responses.

  • Utilize libraries like libmicrohttpd for creating web servers in C.

  • Implement...read more

Are these interview questions helpful?
4d ago

Q. Data structures through c language

Ans.

Data structures in C language are essential for organizing and manipulating data efficiently.

  • Data structures like arrays, linked lists, stacks, queues, trees, and graphs are commonly used in C programming.

  • Arrays are used to store a collection of elem...read more

Asked in Samsung

5d ago

Q. What are storage classes in C? Explain.

Ans.

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

  • There are four storage classes in C: auto, register, static, and extern.

  • Auto variables are local to a block and have automatic storage duration.

  • Register variables are stored in CPU regis...read more

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

Asked in Samsung

5d ago

Q. Write a C program that will compile and run to reverse a string in-place.

Ans.

A C program to reverse a string in-place

  • Use two pointers, one pointing to the start of the string and the other to the end

  • Swap the characters at the two pointers and move them towards each other until they meet

  • Repeat the swapping process until the en...read more

3d ago

Q. What are the key features of the static storage class?

Ans.

Static storage class is used to declare variables that retain their values throughout the program execution.

  • Variables declared with static storage class have a lifetime that extends for the entire duration of the program.

  • They are initialized only onc...read more

5d ago

Q. Implement bit fields and explain with a piece of code.

Ans.

Bit fields are used to allocate specific number of bits in a structure to store and manipulate data efficiently.

  • Bit fields are declared using a colon (:) followed by the number of bits to allocate.

  • They can be used to represent flags, status bits, or ...read more

3d ago

Q. How many classes are there in C? Explain.

Ans.

There are no classes in C as it is a procedural programming language.

  • C is a procedural programming language, not an object-oriented one.

  • It does not have the concept of classes or objects.

  • Instead, it uses functions and structures to organize code.

  • Stru...read more

C Jobs

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

Asked in Cognizant

4d ago

Q. Can you write code in C language?

Ans.

Here is a simple example of a C program that prints 'Hello, World!'

  • Declare a main function

  • Use the printf function to print 'Hello, World!'

  • Return 0 to indicate successful execution

Asked in DXC Technology and 5 others

3d ago

Q. Write a simple C program.

Ans.

A simple C program

  • Include the stdio.h header file

  • Declare the main function

  • Use printf() function to print output

  • Use scanf() function to take input

  • End the program with return 0;

Asked in Altisource

1d ago

Q. How can you find common elements from two arrays using C?

Ans.

Finding common elements in two arrays of strings using C

  • Create two arrays of strings

  • Loop through each element of the first array

  • For each element, loop through the second array to check for a match

  • If a match is found, add it to a third array

  • Return the...read more

Asked in Aptiv

3d ago

Q. What are storage class specifiers in C?

Ans.

Storage class specifiers in C are used to define the scope and lifetime of variables.

  • There are four storage class specifiers in C: auto, register, static, and extern.

  • Auto variables are local to a block and have automatic storage duration.

  • Register var...read more

Asked in Imaginnovate

2d ago

Q. Are any libraries required to perform C programming, and if so, what are they?

Ans.

Yes, some libraries are required for C programming such as stdio.h, math.h, string.h, etc.

  • stdio.h library is used for input/output operations

  • math.h library is used for mathematical operations

  • string.h library is used for string manipulation operations

2d ago

Q. Write a program to implement strcmp.

Ans.

Program to implement strcmp

  • Use a loop to compare each character of the two strings

  • Return 0 if both strings are equal, -1 if s1s2

  • Handle null and empty strings appropriately

3d ago

Q. What is the use of the printf() and scanf() functions?

Ans.

printf() is used to print formatted output to the screen, while scanf() is used to read formatted input from the user.

  • printf() is used to display output on the screen in a formatted way.

  • scanf() is used to read input from the user in a formatted way.

  • E...read more

Q. Which of the following is not a storage class in C? a) auto b) extern c) static d) dynamic

Ans.

In C, 'dynamic' is not a storage class; valid ones include auto, extern, and static.

  • Storage classes define the scope, visibility, and lifetime of variables.

  • auto: Default storage class for local variables, e.g., 'int x;' inside a function.

  • extern: Used...read more

Asked in Adobe

5d ago

Q. What are the four storage classes in C?

Ans.

The four storage classes in C are auto, register, static, and extern.

  • Auto: default storage class for all local variables

  • Register: used to define local variables that should be stored in a register instead of RAM

  • Static: used to define local variables ...read more

Q. What does 'int x:4;' mean? a) x is a four-digit number. b) x is a four-bit integer. c) x cannot be greater than 4 digits. d) None of these.

Ans.

b) x is four bit integer.

  • The statement 'int x:4;' indicates that x is a four bit integer.

  • A four bit integer can have values ranging from 0 to 15.

  • The colon followed by the number 4 specifies the number of bits allocated for x.

5d ago

Q. Write a C program and explain each line.

Ans.

A C program that needs to be written and explained line by line.

  • The program should be written in C language.

  • Each line of the program needs to be explained.

  • The program should use an array of strings.

  • The answer should be returned in JSON format.

Asked in Imaginnovate

5d ago

Q. How can we start a program in the C language?

Ans.

To start a program in C language, we need to write a main function and compile the code.

  • Write the main function with the code to be executed

  • Compile the code using a C compiler

  • Execute the compiled program

  • Optionally, pass command line arguments to the ...read more

2d ago

Q. Write the Test_and_Set program

Ans.

Test_and_Set program is used to ensure mutual exclusion in concurrent systems.

  • Test_and_Set is a hardware instruction that sets a memory location to a value and returns its old value.

  • The program uses a loop to repeatedly execute the Test_and_Set instr...read more

6d ago

Q. Define structure and union in C.

Ans.

Structure and union are two user-defined data types in C used to store multiple data types under a single variable name.

  • Structure is a collection of variables of different data types under a single name.

  • Union is similar to structure but all the varia...read more

Q. What is the difference between delete and free?

Ans.

Delete and free are both used to deallocate memory, but delete is used for objects created with new, while free is used for memory allocated with malloc.

  • delete is used in C++ to deallocate memory for objects created with new keyword

  • free is used in C ...read more

Asked in Qualcomm

5d ago

Q. What do static, volatile, and const mean in C?

Ans.

Static, volatile, const are C keywords used to define properties of variables.

  • Static: used to define a variable that retains its value between function calls

  • Volatile: used to indicate that a variable's value may change unexpectedly, e.g. in an interr...read more

Asked in TCS

3d ago

Q. Why is the main function required in a C program?

Ans.

Main function is required in C program as it is the entry point of the program.

  • Main function is where the program starts executing.

  • It contains the code that initializes variables, calls functions, and performs other necessary tasks.

  • Without main funct...read more

Q. What is the difference between ARR and ADR?

Ans.

Arr and adr are both used in programming, but arr typically refers to an array while adr typically refers to an address.

  • Arr is commonly used to refer to an array in programming, which is a collection of elements stored in a contiguous memory location...read more

3d ago

Q. Explain the entire process of converting an Example.c file to Example.exe.

Ans.

The process of converting Example.c file to Example.exe involves several steps.

  • Preprocessing: includes header file inclusion, macro expansion, and conditional compilation

  • Compilation: converts source code to object code

  • Linking: combines object code wi...read more

4d ago

Q. Who is the founder of the C language?

Ans.

The founder of C language is Dennis Ritchie.

  • Dennis Ritchie is the creator of the C programming language.

  • He developed C language at Bell Labs in the early 1970s.

  • C language is widely used for system programming and developing other programming language...read more

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