VOOZH about

URL: https://www.geeksforgeeks.org/c/c-coding-interview-questions/

⇱ Top 50 C Coding Interview Questions and Answers (2025) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Top 50 C Coding Interview Questions and Answers (2025)

Last Updated : 23 Jul, 2025

C is the most popular programming language developed by Dennis Ritchie at the Bell Laboratories in 1972 to develop the UNIX operating systems. It is a general-purpose and procedural programming language. It is faster than the languages like Java and Python. C is the most used language in top companies such as LinkedIn, Microsoft, Opera, Meta, and NASA because of its performance. To crack into these companies and other software companies, you need to master C.

This interview preparation guide on C Coding Interview Questions offers a comprehensive collection of practice questions suitable for both beginners and advanced learners.

List of 50 C Coding Interview Questions and Answers

Here is a list of 50 C coding interview questions and answers, to fully prepare for your next interview and ace those tough coding challenges, our C programming course offers a complete guide, including mock interview questions and detailed explanations.

1. Find the largest number among the three numbers.


Output
3

Refer to complete article - C program to Find the Largest Number Among Three Numbers

2. Write a Program to check whether a number is prime or not.


Output
91 is NOT prime

Refer to complete article - Prime Number Program in C

3. Write a C program to calculate Compound Interest.


Output
Compound Interest is : 714.830823

Refer to complete article - C Program For Compound Interest

4. Write a Program in C to Swap the values of two variables without using any extra variable.


Output
x: 10 , y: 20
x: 20 , y: 10

Refer to complete article - Swap Two Numbers Without Using Third Variable

5. Write a Program to Replace all 0’s with 1’s in a Number.

Output:

112311

6. Write a Program to convert the binary number into a decimal number.


Output
27

Refer to complete article - Convert Binary to Decimal in C

7.  Write a Program to check if the year is a leap year or not.


Output
2000 is a leap year.
2002 is not a leap year.
2008 is a leap year.

Refer to complete article - Leap Year Program in C

8. Write a program to Factorial of a Number.


Output
Factorial of 13 is 6227020800
Factorial of 9 using recursion:362880

Refer to complete article - Factorial Program in C

9. Write a Program to Check if a number is an Armstrong number or not.


Output
False
True

Refer to complete article - C Program to Check Armstrong Number

10. Write a program to Find all the roots of a quadratic equation in C.

Output:

Roots are real and different
15.937254
0.062746

Refer to complete article - C Program for Quadratic Equation Roots

11. Write a Program to reverse a number.


Output
Initial number:15942
24951 after reverse using iteration
15942 after again reverse using recursion

Refer to complete article - Reverse Number Program in C

12. Check whether a number is a palindrome.


Output
13431 is palindrome
12345 is not a palindrome

Refer to complete article - Palindrome Number Program in C

13. Write a C Program to check if two numbers are equal without using the comparison operator. 


Output
 1 is not equal to 2 

14. Write a  C program to find the GCD of two numbers.


Output
GCD of 98 and 56 is 14 

Refer to complete article - GCD of Two Numbers in C

15. Write a C program to find the LCM of two numbers.


Output
36

Refer to complete article - LCM of Two Numbers in C

16. Write a C Program to find the Maximum and minimum of two numbers without using any loop or condition. 


Output
max = 55
min = 23

17. Write a Program in C to Print all natural numbers up to N without using a semi-colon.


Output
1 2 3 4 5 6 7 8 9 10 

Refer to complete article - C Program to print numbers from 1 to N without using semicolon?

18. Write a Program to find the area of a circle.


Output
Area is 78.550000

Refer to complete article - C Program to Find Area of Circle

19.  Write a Program to create a pyramid pattern using C.


Output
 *
 ***
 *****
 *******
*********

Refer to complete article - C Program to Print Pyramid Pattern

20. Write a program to form Pascal Triangle using numbers.

 1 
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Output
 1 
 1 1 
 1 2 1 
 1 3 3 1 
1 4 6 4 1 

Refer to complete article - Pascal Triangle Program in C

21. Write a Program to return the nth row of Pascal's triangle.


Output
1,5 ,10 ,10 ,5 ,1 

22. Write a program to reverse an Array.


Output
5 4 3 2 1 

Refer to complete article - Reverse Array in C

23. Write a program to check the repeating elements in C.


Output
1 3 5 

24. Write a Program to print the Maximum and Minimum elements in an array.


Output
Smallest: 2 and Largest: 83

Refer to complete article - C Program to Find the Maximum and Minimum Element in the Array

25. Write a Program for the cyclic rotation of an array to k positions.


Output
3 4 5 1 2 

Refer to complete article - C Program for Program for array rotation

26. Write a Program to sort First half in Ascending order and the Second in Descending order.


Output
11 16 23 83 73 59 42 

27. Write a Program to print sums of all subsets in an array.


Output
6 3 4 1 5 2 3 0 

28. Write a Program to Find if there is any subarray with a sum equal to 0.


Output
True subarray with 0 sum is possible

29. Write a C program to Implement Kadane's Algorithm


Output
Maximum contiguous sum is 7
Starting index 2 Ending index 6

30. Write a Program to find the transpose of a matrix.


Output
Result matrix is 
1 2 3 
1 2 3 
1 2 3 
1 2 3 

Refer to complete article - Transpose of a Matrix in C

31. Write a Program to Rotate a matrix by 90 degrees in the clockwise direction in C.


Output
Orignal Matrix:
1 2 3 4 
5 6 7 8 
9 10 11 12 
13 14 15 16 
Matrix after rotation: 
13 9 5 1 
14 10 6 2 
15 11 7 3 
16 12 8 4 

Refer to complete article - Rotate an Image 90 Degree Clockwise

32. Write a Program to find the Spiral Traversal of a Matrix in C.


Output
1 5 9 13 14 15 16 12 8 4 3 2 6 10 11 7 

33. Write a program to count the sum of numbers in a string.


Output
23

34. Program to calculate the length of the string.


Output
length using strlen:13
length using iteration:13
length using recursion:13

Refer to complete article - C Program to Find the Length of a String

35. Write a program to check string is a palindrome.


Output
GeekeeG is a palindrome
Checking GeeksforGeeks using recursive approach
Not a Palindrome

Refer to complete article - C Program to Check for Palindrome String

36. Write a program to print all permutations of a given string in lexicographically sorted order in C.


Output
123 
132 
213 
231 
312 
321 

37. Write a program to calculate the Power of a Number using Recursion in C.


Output
1024

38. Write a Code to print the Fibonacci series using recursion.


Output
Fibonacci using recursion of 9:34
Fibonacci using iteration of 11:144

Refer to complete article - C Program to Print Fibonacci Series

39. Write a Program to find the HCF of two Numbers using Recursion.


Output
GCD of 192 and 36 is 12 

40. Write a Program in C to reverse a string using recursion.


Output
Orignal string:Geeks for Geeks
Reverse the string(iteration):skeeG rof skeeG
Using recursion for reverse:Geeks for Geeks

Refer to complete article - C Program to Reverse a String Using Recursion

👁 Image
C Coding Interview Questions and Answers

41.  Write a C Program to search elements in an array.


Output
Element is present at index 4

Refer to complete article - C Program for Linear Search

42.  Write a C Program to search elements in an array using Binary Search.


Output
Element is present at index 4

Refer to complete article - C Program for Binary Search | GeeksforGeeks

43. Write a C Program to sort arrays using Bubble, Selection, and Insertion Sort.


Output
Non-Sorted array: 9 4 3 11 1 5 
Sorted array using Bubble sort: 1 3 4 5 9 11 
Non-Sorted array: 4 3 9 1 5 11 
Sorted array using Insertion Sort: 1 3 4 5 9 11 
Non-Sorted array: 5 1 11 3 4 9 
Sorted array using Selection Sort: 1 3 4 5 9 11 

44. Write a C Program to sort arrays using Merge Sort.


Output
Given array:23 9 13 15 6 7 
Sorted array :6 7 9 13 15 23 

Refer to complete article - C Program for Merge Sort

45. Write a C Program to sort arrays using Quick Sort.


Output
Unsorted Array:28 7 20 1 10 3 6 
Sorted array :1 3 6 7 10 20 28 

Refer to complete article - Quick Sort in C

46. Write a program to sort an array using pointers.


Output
4 7 12 13 22 

Refer to complete article - C program to sort an array using pointers

47. Write a C program to Store Information about Students Using Structure


Output
Student Records:

 Name : Geeks1 Roll Number : 1 Age : 10
 Name : Geeks2 Roll Number : 2 Age : 11
 Name : Geeks3 Roll Number : 3 Age : 13

Refer to complete article - C Program to Store Information of Students Using Structure

48. Write a C Program To Add Two Complex Numbers Using Structures And Functions.


Output
 x = 4 + 5i
 y = 7 + 11i

 sum = 11 + 16i

49. Write a C Program to add Two Distance Given as Input in Feet and Inches


Output
Feet Sum: 31
Inch Sum: 5.70

Refer to complete article - C Program to Add N Distances Given in inch-feet System using Structures

50. Write a C program to reverse a linked list iteratively


Output
Given linked list
25 19 14 10 
Reversed linked list 
10 14 19 25 

Refer to complete article - C Program for Reverse a linked list

Conclusion

In this C coding interview questions and answers, we've compiled a wide-range of practice questions suitable for individuals at all levels, from beginners to advanced learners. Exploring these questions and their solutions will not only enhance your proficiency in C but also prepare you for a successful coding interview experience.

Comment