Write a program in C++ that creates a class vect, which contains a pointer to an integer (int *ptr) and an integer (size).The integer pointer (ptr) will point to a dynamic array of integers and size represents the total capacity of that dynamic array. The class vect should behave as an array with practically unlimited entries.
a) Write a default constructor that will initialize integer pointer (ptr) to NULL
and integer variable (size) to zero.
b) Write a parameterized constructor that will initialize integer variable (size)
to a value passed as parameter. Initialize the integer pointer (ptr) to a
dynamic array of size that equals to the parameter that is passed to
constructor.
Write a program to declare three classes a1, a2, a3. The classes have private data member variable of string type. Assign the first name and surname of a student to member variable of class a1 and a2 respectively. Perform concatenation of two strings and store it to data member variable of class a3. Print the full name to the output screen using member function.
Design a class Student. Include data members rollno, name, city and age. Write member functions:
i) To accept information of ‘n’ students
ii) To display information of ‘n’ students
iii) To search details of a student using rollno
(use array of objects)
Iv. Calculate Average age.
Write a Program to declare examination results. Design three classes: Student, Exam, Result. The Student class has the data members such as Rollno and name. Create the class Exam by inheriting the Student class. The Exam class includes the data members representing the marks scored in six subjects. Derive the Result from Exam class and it has its own data members such as Total marks as well as calculate the grade based on total marks. Display the result with all the student information in descending order of their grade.
Roll an N-sided die until the sum of the numbers drawn is greater than X (N and X chosen by the user)
Define a class named ‘bank account’to represent following members:
Data members :-
- account number
- name of depositor
- account type
- balance amount
Member functions:
- Initialise members
- deposit amount
- display balance
Write a C++ program to test the train class.
Write a C++ code that will conduct an interview for stewardess. If all the criteria as in the table below is fulfilled, the result will be “You Got The Job”. For unsuccessful candidates, the result will be “Try Again”. Unsuccessful candidates are those who did not fulfil the criteria below.
Age-Between 20 till 25
Height-Between 168 cm till 175 cm
Weight-Between 45 till 50 kg
English grade - A or B
Create a class which stores x and y coordinates of a point using Overload.
Write function to ‘power’ which
-calculates square of a number when one argument is provided.
-calculates x raised to power y when two arguments are provided.
-calculates x raised to power y, raised to power z, when three arguments are provided.
Create a class inventory which stores code, cost, count and total cost of an item. Calculate total cost inside parameterized constructor. Include a function sale which takes sale quantity as argument and updates count and total cost. Include another function purchase which takes purchase quantity as argument and updates count and total cost. Both the sale and purchase function should use quantity as 1 when no argument is provided.