top of page

C Programming, Sample quiz assignment


Write a C program that asks the user for the name of a file. Read the file for an arbitrary number of integers, and insert them into a singly linked list.

Now ask the user to enter a number, say n. Use binary search to search for n and return the result of the search.


Input: numbers.txt

10 –> 20 –> 30 –> 40 –> 50 –> NULL

Enter n = 40

Output: Found at node number 4!

Write a python program to read a file named substrings.txt for an arbitrary number of strings. Write a function to concatenate the strings in all pairwise combinations and print out all combinations of strings that are palindromes.


substrings = [“aba”, “mo”, “om”]









ommo, moom

Write a C program to find the total number of balanced parentheses - only (, ) using a LL based stack:


Input: ( ( ( ) ( ) Input: ( ( ( ( Input: ( ( ) ( ) ) ( ( )

Output: 4 Output: 0 Output: 6

Akhil wants to keep track of the inventory at his new Drug Store using a linked list. Write a menu driven program with the following functions:

  • Add Medicine: Ask for the name of the medicine from the user and create a new node. Set quantity = 1

  • Purchase Medicine: Increase quantity of Medicine a by x (ask the user for a, x)

  • Sell medicine: Decrease quantity of medicine a by x (ask the user for a, x). Remember you can only sell how much medicine you have! If quantity goes below zero, remove the medicine from the list.

  • Display inventory: Display all medicines and their quantity

Write a program in C to take 2 input strings from the user:

Use insertion sort to sort each string into alphabetical order. Check if the sorted strings are the same (not case sensitive), if yes, that means that the original strings were anagrams.


Input : s1 = "listen" s2 = "silent"

Output : s1 = eilnst

s2 = eilnst

The strings are anagrams!

Input : s1 = "bad" s2 = "dad"

Output : s1 = abd

s2 = add

The strings are not anagrams.

Input: s1 = “death” s2 = “HATED”

Output: s1 = “adeht”

s2 = “ADEHT”

The strings are anagrams!

bottom of page