C++ Programming Questions 2017
- Design and implement a class “New_stack” which has all the operation of a stack and other necessary functions. Create an object of this class and use this object to solve the postfix expression : 5 10 +
- Create a class “Student” which contains the following data items:
- Student Name
- Student Enrollment Number
- Programme Code
- Phone number
Design and implement a constructor that initializes all the four data members. Write a function that allows change of phone number. Write a destructor function also.
- Design and implement a class “Queue” which has functionality of Queue data structure. Use this class to create a simple queue object of integers having input queue values -10 20 30.
- Design and implement a class called “My_sort_array”. The class contains an array of sorted integer data. The constructor of the class can take 3 input values and put them in sorted order in the array. Also write one or more function that adds a new value in the sorted array (obviously in sorted order).
- Design and implement a class “Linked_first”, which is a linked list where insertion of a new element is possible only at start or first node.Implement the class and show the insertion two nodes. Also write a function that displays the complete linked list.
- Design and implement a class that can store a line segment that is being represented by two points (assume only two dimensional points). Implement the necessary constructors. Also write a function that finds the length of the line segment.
- Design and implement a class “MyMatrix” that can store a matrix as a two dimensional array size 3*3. The class have a constructor that initializes all the elements of array to 0. Also write two functions one for displaying the matrix and one for input of the elements of matrix. Finally, write an overloaded multiplication (*) operator that multiplies two matrices.
- Design and implement a class “MyDate” using C++ that stores day, month and year as variable. The class has a constructor that initializes the date to ’01-01-2001’. The class has a function that allows changes in the date, but only after proper checking about the validity of the date. You may assume that this date class can have date in the range 01-01-2001 to 01-01-2020. The class has an overloaded minus operator (-) function that finds the difference in the years of the two dates and a function to display the date.
- Design and implement a class “MyArray” using C++ that stores a single dimensional array of a maximum size 10. An array in this class may consist of upto 10 elements. The size of stored array is also kept in a number variable. The class should have appropriate constructor. Also implement an overloaded ‘+’ operator that allows addition of two arrays as follows:
- If the size of the two arrays being added is not same it returns an error message.
- Otherwise it adds each corresponding elements of the array.
- Design and implement a class Daymonth using C++. The Daymonth class stores the day and month of the current year in two variables. ( For example 5th March 2009 will be stored as dd=5 and mm=3). This class has a function to find the day of the year. ( For example, 5thMarch is 31+28+5 = 64th day of the year 2009). The class also has a function to print the data stored in the object. Implement the class with suitable constructor, and member variables.
- Design and implement a class new_vector using C++. The new_vector class stores a vector of 3 elements into a single dimensional array of 3 elements. The class has functions to input a vector of 3 elements, add two vectors and subtract tow vectors. Also write the function to output a vector. Make suitable assumption.
- Design and implement a class my_prime using C++. The my_prime class stores the first seven prime numbers viz. (2,3,5,7,11,13,17) in an array. The class determines the whether an input value (it should be between 1 and 400) is a prime or not. The input value is stored in the class variable n by a function. The class also has a function that determines if n is prime or not. This information is output by an output function. You need to design the class and implement all the function along with an appropriate main() function.
- Design and implement using C++ a class “New_complex” that stores a complex number. The class should have overloaded constructors and an overloaded operator “+” that will allow addition of two complex numbers. The class should also have a function for input of complex number and another function to display the complex number.
- Design and implement a class twoDarray using C++. The class stores data in a two dimensional aftay of size 3 x 3. The class should have a constructor that assigns input values to the array elements. The class should have two additional functions – first to output the array values – element by element and second to search a specified value in the array. Implement the class with appropriate member variables and functions. You must write the appropriate main( ) function to demonstrate all the functions of the class.
- Design and implement a class linked-list. Write a C++ program that merges two linked lists into a single separate linked list. Each node in a linked list should have two fields :
- Data field having integer value.
- Pointer field having pointer to next node.
- Design and implement a class “Smatrix” of the type Square Matrix of real numbers and overload the operator “+” to find the sum of two objects of the type Smatrix.
- Write a c++ program to generate a series of Armstrong Numbers.(Note : Armstrong number is a number whose sum of the cube of its digits is equal to the number. e.g. 153)
- Create a class “time” that has separate int data member for hours, minutes and seconds. One constructor should initialize this data to 0 and another should initialize it to fixed values. Write a member function to display the time in the format 11 : 40 : 30. The final member function should add two objects of type time passed as argument.
- Write a C++ program that reads a string from the console and prints it in the reverse order. Also, if any character in the input string is in uppercase the output should be uppercase or vice-versa.
- Design and implement a class MyArray for string manipulations. Read two strings and overload the operator’ +’ to concatenate them, store the results of concatenated strings in a member of MyArray class. Write appropriate constructor and destructor for class MyArray. Also, display the size of concatenated string using MySize( ) function.
- Design and implement a class “My-Queue” using C++. Create two objects of My-Queue class and put different character strings in both the objects. Now, compare whether the values in both the objects are same or not.