Skip to content

OEXPL TEST PROGRAMS

Test Program 1 : Binary Search Tree

This test program inserts elements into a binary search tree and prints the elements in inorder, preorder and postorder traversal. The program stops taking input elements (that are to be inserted in Binary Search Tree) when the user enters 0.

Input : The elements that are to be inserted into a Binary Search Tree and a 0 at last (indicating the end of input).

Output : The inorder, preorder and postorder traversal of the tree.

This program test the iteration, recursion, conditional, arrays and passing of user-defined datatype as return value of function.

The code for the test progam can be found here

Test Program 2 : Linked list

This test program reads elements into a linked list and prints them.

Input : Value of length of list and list of values from standard input.

Output : The list of values stored in linked list.

This program test the working of dynamic memory allocation functions like Initialize(), Alloc() and Free().

The code for the test progam can be found here

Test Program 3 : Sum of Factorials

This test program reads an element and finds the sum of factorials of all the numbers till that element.

Input : Value of n.

Output : Sum of factorials of all the numbers till n.

This program tests the declaration of a member field which is an object of another class. This program also tests the recursion, parameter passing, calling a function inside the call of another function.

The code for the test progam can be found here

Test Program 4

This program tests the runtime binding of the variables of a class.

Input : If any input > 0

Output : In A F1 0

Input : If any input <= 0

Output : In B F1 1

This program uses the concepts of inheritance and subtype polymorphism.

The code for the test progam can be found here

Test Program 5

This program tests the correct set up of the virtual function table by the compiler.

Input : If n < 0

Output : In A F0

Input : If n == 0

Output : In B F0

Input : If n > 0

Output : In C F0

This program uses the virtual function table, inheritance and subtype polymorphism.

The code for the test progam can be found here

Test Program 6

This program tests the implementation of inheritance and subtype polymorphism.

Input : 1 length breadth

Output : length * breadth

Input : 2 length

Output : length * length

This test program uses the concepts of inheritance.

The code for the test progam can be found here

Test Program 7

This program tests the implementation of inheritance and subtype polymorphism.

Input : > 0

Output : Rogers 37

Input : <= 0

Output : Mathew 35 999 CS

This program tests the concepts of inheritance, subtype polymorphism and virtual function table.

The code for the test progam can be found here