Top 150 C Interview Questions and Answers
Updated 5 Mar 2025
Q101. #define a 3+3 #define b 11-3 main() { printf(?%d?,a*b); } wat is o/p?????
This is a programming question involving preprocessor directives and printf function.
The preprocessor directives #define a 3+3 and #define b 11-3 will be replaced by their respective values during compilation.
The main function will print the result of a*b, which is equivalent to 6*8.
Therefore, the output will be 48.
The printf function will print the integer value of 48.
Q102. What is the difference between continue and break statement in C language??
Continue statement skips the current iteration of a loop and moves to the next one, while break statement terminates the loop.
Continue statement is used to skip a particular iteration of a loop and move to the next one.
Break statement is used to terminate the loop and move to the next statement outside the loop.
Continue statement is used when we want to skip a particular iteration of a loop based on some condition.
Break statement is used when we want to terminate the loop bas...read more
Q103. What is data type and what are data types in c programming
Data type is a classification of data items based on the type of value they hold. C programming has various data types.
Data type determines the type of data that can be stored in a variable
C programming has basic data types like int, float, char, double, etc.
C programming also has derived data types like arrays, pointers, structures, unions, etc.
Q104. Can I compile c program without main ()
Yes, it is possible to compile a C program without main().
A C program must have a main() function as the entry point.
However, it is possible to compile a C program without a main() function using a different entry point.
This can be achieved by defining a different entry point using linker options or compiler-specific attributes.
For example, in some embedded systems, the entry point may be defined as _start() instead of main().
Q105. What is structure and union in c?
Structure and union are two user-defined data types in C used to store multiple variables of different data types.
Structure is a collection of variables of different data types under a single name.
Union is a special data type that allows storing different data types in the same memory location.
Structures are used to represent a record while unions are used for memory optimization.
Structures use the dot operator to access members while unions use the same memory location for a...read more
Q106. 3) What is malloc and calloc?
malloc and calloc are functions used for dynamic memory allocation in C programming language.
malloc() allocates a block of memory of specified size and returns a pointer to the first byte of the allocated memory.
calloc() allocates a block of memory of specified size and initializes all the bytes to zero.
Both functions are used to allocate memory dynamically during runtime.
The memory allocated by these functions must be freed using the free() function to avoid memory leaks.
Q107. How does the C Libraries works ?
C libraries provide pre-written code for common tasks in C programming language.
C libraries contain pre-written code for common tasks such as string manipulation, memory allocation, and input/output operations.
They are included in C programs using the #include directive.
Examples of C libraries include stdio.h, string.h, and math.h.
C libraries can be used to simplify programming tasks and improve code efficiency.
They are often open source and can be modified and shared by deve...read more
Q108. How many bits are there in C
C is a programming language and does not have a fixed number of bits.
C is a high-level programming language that can be compiled to run on different architectures with varying bit sizes.
The number of bits in C depends on the hardware architecture it is compiled for.
For example, C code compiled for a 32-bit architecture will have 32-bit integers, while code compiled for a 64-bit architecture will have 64-bit integers.
C Jobs
Q109. In c programming # stands for?
In C programming, # stands for preprocessor directive.
The # symbol is used to indicate a preprocessor directive in C programming.
Preprocessor directives are instructions to the compiler that are executed before the compilation process.
They are used to include header files, define constants, perform conditional compilation, etc.
Examples of preprocessor directives include #include, #define, #ifdef, #ifndef, etc.
Q110. What is isr routine in c programming
ISR routine is a function that is executed in response to an interrupt signal.
ISR stands for Interrupt Service Routine
It is used to handle hardware interrupts
ISR routines are written in C language
They are executed when an interrupt signal is received
ISR routines should be short and efficient
They should not block other interrupts
Examples of ISR routines include handling keyboard input or timer interrupts
Q111. What is c prominent language?
C is a prominent programming language used for system programming and developing operating systems.
C was developed by Dennis Ritchie at Bell Labs in 1972.
It is a compiled language and is known for its efficiency and low-level memory manipulation capabilities.
C is used for system programming, developing operating systems, embedded systems, and game development.
Some popular software written in C include the Linux kernel, MySQL, and Adobe Photoshop.
C++ and Objective-C are both d...read more
Q112. Find a number in the string? C program for finding greatest of 3 numbers? RTOs related questions.
C program for finding greatest of 3 numbers and finding a number in a string. RTOs related questions.
For finding greatest of 3 numbers, use if-else statements and compare each number with the other two.
For finding a number in a string, use string manipulation functions like strstr() or atoi().
For RTOs related questions, brush up on traffic rules and regulations specific to your region.
Q113. 1. What is structure and union
Structure and union are data structures in C programming language.
Structure is a collection of variables of different data types under a single name.
Union is a special data type that allows storing different data types in the same memory location.
Structures are used to represent a record while unions are used for memory optimization.
Structures are accessed using dot (.) operator while unions are accessed using arrow (->) operator.
Q114. Have you ever made a thread based program in c?
Yes, I have made a thread-based program in C.
Threads in C allow for concurrent execution of multiple tasks.
Threads can be created using the pthread library in C.
Thread-based programs can improve performance and responsiveness.
Example: Creating multiple threads to perform parallel processing tasks.
Q115. WAP in c to find the reverse of a number
WAP in C to find the reverse of a number
Take input number from user
Initialize a variable to store the reverse of the number
Use a while loop to extract the last digit of the number and add it to the reverse variable
Divide the number by 10 to remove the last digit
Repeat until the number becomes 0
Print the reverse of the number
Q116. "Dynamic Array in C" problem from hackerrank.com
Dynamic Array in C - Implement a dynamic array to store strings in C language.
Use malloc() to allocate memory for the array.
Use realloc() to resize the array when needed.
Use strcpy() to copy strings into the array.
Use free() to deallocate memory when done.
Q117. What I'd c language ?
C is a general-purpose, procedural programming language.
C was developed by Dennis Ritchie at Bell Labs in 1972.
It is widely used for system programming, embedded systems, and game development.
C is a compiled language and has a low-level memory manipulation feature.
It has influenced many other programming languages such as C++, Java, and Python.
Q118. 5.Write any program in c language
Program to print 'Hello, World!' in C language
Include stdio.h header file
Use printf() function to print the message
End the program with return 0 statement
Q119. 30)Write a c program to select a contiguous subarray of size m from an array such that its sum is closest to zero
This C program selects a contiguous subarray of size m from an array with the sum closest to zero.
Iterate through the array and calculate the sum of each subarray of size m
Keep track of the subarray with the closest sum to zero
Return the subarray with the closest sum to zero
Q120. Different between calloc()and malloc()
calloc() and malloc() are both used for dynamic memory allocation in C, but calloc() also initializes the allocated memory to zero.
calloc() allocates memory for an array of elements and initializes them to zero.
malloc() only allocates memory for the specified number of bytes.
calloc() is useful when initializing arrays or structures.
malloc() is useful when allocating memory for a single variable or a dynamically sized array.
Q121. 2.Tell about memory layout in c
Memory layout in C refers to the organization of memory for variables and data structures.
Memory is divided into 3 sections: Text segment, Data segment, and Heap segment.
Text segment contains the executable code.
Data segment contains global and static variables.
Heap segment contains dynamically allocated memory.
Stack segment contains function calls and local variables.
Q122. What is oops language in C
There is no OOP language in C, but C++ is an OOP language that is derived from C.
C++ is an extension of C that supports OOP concepts like encapsulation, inheritance, and polymorphism.
C++ allows the creation of classes and objects, which are the building blocks of OOP.
C++ also supports features like templates, exceptions, and namespaces that make it a powerful language for software development.
Q123. C -25% mn- 60%+ si- 20 -30% s- 40% P- 40% s+p 75%
The question seems to be related to the chemical composition of a material.
The material contains 25% Mn, 60%+ Si, 20-30% S, and 40% P.
The total percentage of S and P in the material is 75%.
The material may be used in the manufacturing of steel or other alloys.
The inspector should be familiar with the chemical properties of the material and its intended use.
Q124. What is datastructure in c
Data structure in C refers to the way data is organized and stored in memory.
Data structures in C provide efficient ways to store and manipulate data.
Examples of data structures in C include arrays, linked lists, stacks, queues, and trees.
Data structures help optimize memory usage and improve program efficiency.
They enable efficient searching, sorting, and retrieval of data.
Understanding data structures is crucial for developing efficient software applications in C.
Q125. Tell us About C programming language
C programming language is a high-level programming language used for system programming and developing applications.
C is a compiled language
It is a procedural language
C has a rich library of built-in functions
C is used for developing operating systems, compilers, and embedded systems
C is known for its efficiency and speed
C supports pointers and memory management
C is widely used in the development of games and other high-performance applications
Q126. What is c program?
C program is a computer program written in the C programming language.
C is a high-level programming language.
C programs are compiled using a compiler.
C programs are used to develop operating systems, software applications, and embedded systems.
C programs use variables, data types, control structures, and functions.
Example: Hello World program in C.
Q127. What is c? How it's function work
C is a programming language used for system programming, embedded systems, and game development.
C was developed by Dennis Ritchie at Bell Labs in 1972.
It is a compiled language, meaning that the code is translated into machine-readable instructions before execution.
C is known for its efficiency and low-level control over hardware, making it a popular choice for operating systems and device drivers.
C functions are defined with a return type, name, and parameters, and can be ca...read more
Q128. What is the difference betwe en nill pointer and void pointer
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 void pointer.
A null pointer is used to indicate that a pointer does not point to a valid object.
A void pointer is used to store a pointer to any type of object.
Q129. write a pgm to swap two variable withought using third variable
Program to swap two variables without using a third variable.
Use arithmetic operations to swap the values
Use XOR operator to swap the values
Use tuple packing and unpacking to swap the values
Q130. What is c?? Tell me about c briefly
C is a programming language developed by Dennis Ritchie in 1972.
C is a general-purpose programming language
It is widely used for system programming, embedded systems, and game development
C is a compiled language, meaning that the code needs to be compiled before it can be executed
It is known for its efficiency and low-level programming capabilities
C has influenced many other programming languages, including C++, Java, and Python
Q131. What is string in c language
A string in C language is a sequence of characters stored in an array.
Strings in C are represented as arrays of characters.
They are terminated by a null character '\0'.
Strings can be manipulated using various string functions like strcpy, strcat, etc.
Q132. What is a c laguage what is data
C language is a programming language used for system programming and data is information processed or stored by a computer.
C language is a general-purpose programming language known for its efficiency and low-level programming capabilities.
Data refers to information that is processed or stored by a computer, such as numbers, text, images, etc.
C language allows programmers to manipulate and work with data using variables, data types, and functions.
Example: In C language, you c...read more
Q133. What is the use of printf() and scanf ()?
printf() is used to print formatted output to the console, while scanf() is used to read formatted input from the console.
printf() is used to display output on the console, allowing for formatting options like specifying the number of decimal places or padding with leading zeros.
scanf() is used to read input from the console, allowing for formatting options like reading integers, floats, or strings.
Both functions are part of the standard input/output library in C and are comm...read more
Q134. Swap two number without using pointer?
Swapping two numbers without using pointers
Use arithmetic operations to swap the values
Use XOR operator to swap the values
Use temporary variable to swap the values
Q135. C - What does keyword Extern do?
Keyword Extern is used to declare a variable or function that is defined in another file.
Extern keyword is used to tell the compiler that the variable or function is defined in another file.
It is commonly used in header files to declare variables or functions that are defined in source files.
Extern keyword is not used when defining the variable or function, only when declaring it.
Example: extern int x; // declares variable x that is defined in another file
Example: extern void...read more
Q136. Difference between array and pointers
Arrays are a collection of elements of the same data type, while pointers are variables that store memory addresses.
Arrays are accessed using indices, while pointers are accessed using dereferencing.
Arrays have a fixed size, while pointers can be dynamically allocated.
Arrays can be directly assigned values, while pointers need to be assigned memory addresses.
Arrays can be passed as arguments to functions, while pointers can be used to modify values in functions.
Q137. Write programme in c language
Program to print 'Hello, World!' in C language
Include stdio.h header file
Use printf() function to print 'Hello, World!'
Return 0 at the end of the program
Q138. WHAT TYPE OF A LANGUAGE IS C ?
C is a procedural programming language known for its efficiency and low-level control over hardware.
C is a general-purpose language used for system programming, embedded systems, and application development.
It is a compiled language that allows direct memory manipulation and low-level access to hardware.
C is known for its simplicity, portability, and efficiency.
Examples of C-based software include operating systems like Unix, programming languages like Python, and game engine...read more
Q139. explain storage classes
Storage classes define the scope and lifetime of variables in C programming language.
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 registers for faster access.
Static variables have a lifetime throughout the program and are initialized only once.
Extern variables are declared outside of any function and can be accessed by any function in the pro...read more
Q140. Explain storage classes, memory layout of c?
Storage classes in C define the scope and lifetime of variables.
C has four storage classes: auto, register, static, and extern.
Auto variables are local to a block and have automatic storage duration.
Register variables are stored in CPU registers for faster access.
Static variables have a lifetime throughout the program and are initialized only once.
Extern variables are declared in one file and can be accessed in other files.
Memory layout of C includes stack, heap, and data seg...read more
Q141. Do you like C programming language?
Yes, I like C programming language.
I find C to be a powerful and efficient language for low-level programming.
It has a rich library of functions and is widely used in operating systems and embedded systems.
C is also a great language for learning computer science fundamentals.
For example, I have used C to implement data structures like linked lists and binary trees.
Q142. What is static and dynamic memory allocation?
Static memory allocation is done at compile-time, while dynamic memory allocation is done at runtime.
Static memory allocation is used for variables that are fixed in size and do not change during program execution.
Dynamic memory allocation is used for variables that can change in size during program execution.
Static memory allocation is faster than dynamic memory allocation.
Dynamic memory allocation is useful when the size of the data is not known at compile-time.
Examples of ...read more
Q143. What is offset, if offset what is the result
Offset is the distance between a reference point and the actual point of interest, resulting in a deviation from the intended position.
Offset is the difference between the desired position and the actual position of an object or component.
It can be positive or negative, indicating whether the actual position is to the right or left, above or below, etc.
In aerospace design, offset can affect the aerodynamics, stability, and overall performance of an aircraft or spacecraft.
For ...read more
Q144. Write a C program to swap two numbers
A C program to swap two numbers
Declare two variables to store the numbers
Take input for the two numbers
Swap the values using a temporary variable
Print the swapped values
Q145. Write C code for any problem
C code to find the sum of elements in an array
Declare an array of integers
Initialize the array with values
Use a loop to iterate through the array and add each element to a variable
Print the sum of the elements
Q146. Write an example for structure in c language.
A structure in C is a user-defined data type that allows you to combine different types of variables under a single name.
Structures are used to represent real-world entities or concepts in programming.
They can contain variables of different data types, including other structures.
Structures provide a way to organize related data and improve code readability and maintainability.
You can access the members of a structure using the dot (.) operator.
Structures can be passed as func...read more
Q147. Why you used C language in test
C language is used in test due to its efficiency and low-level control over hardware.
C is a low-level language that allows for direct manipulation of hardware
C is efficient in terms of memory usage and execution speed
C is widely used in embedded systems and operating systems
C allows for easy integration with assembly language
Examples of C-based tests include system-level testing and hardware testing
Q148. Distinguish Call by value and call by reference in C programming?
Call by value passes a copy of the actual parameter, while call by reference passes the address of the actual parameter.
Call by value: actual parameter values are copied into formal parameters. Changes made to formal parameters do not affect actual parameters.
Call by reference: actual parameter addresses are passed into formal parameters. Changes made to formal parameters affect actual parameters.
Example: Call by value - int a = 5; func(a); // a remains 5. Call by reference -...read more
Q149. How is Function declared in c language?
A function in C is declared by specifying the return type, function name, and parameters (if any).
The return type specifies the type of value the function will return.
The function name is used to call the function.
Parameters are optional and specify the input values the function expects.
Function declaration ends with a semicolon.
Q150. Wap to toggle the fourth bit of given number..?
Toggle the fourth bit of a given number.
Extract the fourth bit using bitwise AND operation with 8 (1000 in binary)
Toggle the fourth bit using bitwise XOR operation with 8 (1000 in binary)
Q151. What is the c language band which function is used
The c language band which function is used is stdio.h
The stdio.h library provides input/output functions for C programs
Functions like printf(), scanf(), fopen(), fclose(), etc. are included in stdio.h
The band which function is used is determined by the specific function being called
Q152. What is the reverse of malloc () function?
The reverse of malloc() function is free().
The malloc() function is used to allocate memory dynamically.
The free() function is used to deallocate the memory allocated by malloc().
Freeing memory is important to prevent memory leaks and optimize memory usage.
Top Interview Questions for Related Skills
Interview Questions of C Related Designations
Interview experiences of popular companies
Reviews
Interviews
Salaries
Users/Month