C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Consider following code and state the order of execution constructors and order of execution of destructors.


class C: public A, virtual public B

{    public:

C( ):A( ),B( )

{

cout<<”c class constructor”;

}

};



Include the definition for the function ‘max_age’, in the program given below. The function compares the data member age of the objects P1 and P2 and returns the object having higher value for age.


class person

{ int age;

 public:

person(int a){age=a;}

};

 

int main()

{ person P1(1.5);

  person P2(2.5);

  person P3=P1.max_age(P2);

 }



Find the errors in the following program and correct them.

[Assume the necessary header files and namespaces included


class test

{   static int x;

    int y;

public:

    test( ){x=0;y=0;}

        static void display()

        { cout<<x<<”\t”<<y<<endl; }

        void output()

        {cout<<x<<”\t”<<y<<endl;}

 };

int main()

{  test T1;

   T1.display();

   test::output();

   return 0;

}



Declares an array of 20 components; initializes list[0] to 4 and list[1] to 7; all other components are initialized to 0.


An array is type of data structure that stores the elements in contiguous block of memory, create an array with name "list" and size of an array is N. your task is to print the array elements in an reverse order.


list-[1,2,3,4,5)


output 5,4,3,2,1


Note: use function concept to process the array elements and print it in the reverse order.


Reverse array has the following parameter


int list[n]


return int


Write a program of a menu-driven interface to offer the user four options as follows:
Enter a choice:
0 Print the array of grades
1 Find the minimum grade
2 Find the maximum grade
3 Print the average on all tests for each student
4 End program
Functions should be implemented using pass by reference method. The memory for the array
should be allocated dynamically
Write a program that compares two given dates. To store date use structure say date that
contains three members namely date, month and year. If the dates are equal then display message
as "Equal" otherwise "Unequal". Create a user defined function Compare_Date() to do so which
takes pointer to structure as input.
Given an array, write a user defined function to reverse every sub-array formed by
consecutive k elements. The array should be passed by reference to the function.

Write a Menu driven Program which include these operations like Creating an array, insertion, deletion and fetching all the elements from an array?


create a class student which store name roll no. age of the student. Derive a class test from student class which store marks of 5 subjects input and display the details of student


LATEST TUTORIALS
APPROVED BY CLIENTS