Exercises in C Programming



Are you looking to improve your skills in C programming. Practice the following C exercises. These exercises are addressed for beginners as well as for expert programmers.
Latest added exercises:
  • Reverse the order of appearance of elements in an array: Write the function int READDIM() that reads and returns a strictly positive integer less than 50; Write the function void READARRAY(int Arr[], int N) that reads N integers of the array Arr; Write the function void DISPLAY(int Arr[], int N) that displ...
  • Appending 2 strings in a third: Write a program that reads two strings STR1 and STR2, then appends them in a third string STR3 without using any predefined function from the string.h library.Each of the 3 strings can contain 20 characters at maximum.The program should test if the t...
  • Displaying nth term of 2 series: Write a program that reads a positive integer n and then displays the nth term of the following series : \(\Big\{\begin{array}{c c c} U_0 & = & 1 \\ U_n & = & V_{n-1}+1 \end{array}\) \(\Big\{\begin{array}{c c c} V_0 & = & 0 \\ V_n & = & 2 \times U_{n-1} \end{array}\)...
  • Kth largest element in an array: Write the function \(\texttt{int READDIM()}\) that reads and returns a strictly positive integer less than 50; Write the function \(\texttt{void READARRAY(int Arr[], int N)}\) that reads \(\texttt{N}\) positive integers of the array \(\texttt{Arr}\);...
  • Append the same string: Write a program that reads a string \(\texttt{STR}\) from the keyboard and then adds the reverse of \(\texttt{STR}\) to its end (i.e. \(\texttt{STR}\) should contain the original string and its reverse).You may assume that the size of the string \(\texttt{STR}\)...
  • Inverse summation of 2 arrays: Write a program that: reads the effective dimension \(\texttt{N}\) of an array (maximum dimension: 50 components); then fills two arrays \(\texttt{A}\) and \(\texttt{B}\) each with \(\texttt{N}\) integers entered on the keyboard; then fills a third a...
  • Finding floor and ceil of a value in a Binary Search tree: Given a \(\texttt{BST}\) containing $n$ nodes, write a function that runs in \(\mathcal{O}(\log{}n)\) that finds the \(\texttt{floor}\) and the \(\texttt{ceil}\) of a value \(\texttt{val}\) given as parameter.If \(\texttt{val}\) exists in the tree, i...
  • Checking if a binary tree is a sumTree: A binary tree is called \(\texttt{SumTree}\) if the value of each non-leaf node is equal to the sum of the nodes present in its left subtree and its right subtree.An empty tree is considered as a \(\texttt{SumTree}\) and the sum of an empty tree is e...
  • Level of a binary tree having the highest sum: Write a function that returns the level having the highest sum of its values. We assume that the root of the tree is at level 1, and that the tree is dynamically implemented. Without performing any calculations, give the worst case time complexity of...
  • Trace of adding elements to a hash table: Given the elements {4371, 1323, 6173, 4199, 4344, 9679, 1989}, a fixed hash table size of 10, and the hash function \(\texttt{H(X) = X mod 10}\), show for each of the following collision resolution techniques, the final hash table after inserting eac...
Latest added exam sessions: