Try to solve 6 C interview questions below. Hints can help you find answers to questions you are having trouble with.

1. Palindrome


A palindrome is a word that reads the same backward or forward.

Write a function that checks if a given word is a palindrome. Character case should be ignored. If the given word is a palindrome, the function should return 1; otherwise it should return 0.

For example, is_palindrome("Deleveled") should return 1 as character case should be ignored resulting with "deleveled" which is a palindrome since it reads same backward and forward.


  •   Example case: Wrong answer
  •   Lowercase words: Wrong answer
  •   Various words: Wrong answer

2. Words

Algorithmic thinking Sorting

Implement function sort_words that sorts an array of words that contain lowercase characters from english alphabet, in descending order, and is efficient with respect to time used.

For example, the array { "cherry", "orange", "apple" } should, after sorting, become { "orange", "cherry", "apple" }.


  •   Example case: Wrong answer
  •   Several words: Wrong answer
  •   Performance test on a dictionary: Wrong answer

3. Binary Search Tree

Algorithmic thinking Recursion Tree

Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values iA three-node binary tree.n all the nodes in that node's left subtree and smaller than the values in all the nodes in that node's right subtree.

Write a function that, efficiently with respect to time used, returns 1 if a given binary search tree contains a given value, else 0.

For example, for the following tree:

  • n1 (Value: 1, Left: null, Right: null)
  • n2 (Value: 2, Left: n1, Right: n3)
  • n3 (Value: 3, Left: null, Right: null)

Call to contains(&n2, 3) should return 1 since a tree with root at n2 contains number 3.


  •   Example case: Wrong answer
  •   Correctness: Wrong answer
  •   Performance test on a large tree: Wrong answer

4. Inspect Bits

Bit manipulation

Implement the inspect_bits function that checks if given number contains 2 or more consecutive ones in its binary representation. If it does, the function should return 1. Otherwise, it should return 0.

For example, inspect_bits(13) should return 1 as it contains 2 consecutive ones in its binary representation (1101).


  •   Example case: Wrong answer
  •   Various numbers: Wrong answer

5. Quadratic Equation


Implement the function find_roots to find the roots of the quadratic equation: ax2 + bx + c = 0.

The roots of the quadratic equation can be found with the following formula: A quadratic equation.

For example, the roots of the equation 2x2 + 10x + 8 = 0 are -1 and -4.


  •   Sample case: Wrong answer
  •   Integer roots: Wrong answer
  •   Real roots: Wrong answer

6. Watched Videos

Arrays Pointers

Implement the count_views function. It accepts an array of pointers to the Viewer struct, the size of the array, and the character array with the video name. It should return the number of Viewers who have watched a Video with the name video_name.

For example,

Video videos[] = { {.name = "Soccer", .unique_views = 500},
                   {.name = "Basketball", .unique_views = 1000} };
Viewer viewer = {.username = "Dave", .watched_videos = videos,
                 .watched_videos_size = 2};    
Viewer *viewers[] = { &viewer };

calling count_views(viewers, 1, "Soccer") should return 1.


  •   Example case: Wrong answer
  •   Some people did not see the video: Wrong answer
  •   Various people and videos: Wrong answer

If you feel ready, take one of our timed public C Interview Questions tests:

C Online Test (Easy)

Not exactly what you are looking for? Go to our For Jobseekers section.