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

Q2: Answer the questions (i) to (iv) based on the following:
class Publisher
{
char pub[12];
double turnover;
protected:
void register();
public:
Publisher();
void enter();
void display();
};

class Branch
{
char city[20];
protected:
float employees;
public:
Branch();
void haveit();
void giveit();
};

class Author : private Branch, public Publisher
{
int acode;
char aname[20];
float amount;
public:
Author();
void start();
void show();
};
i. Write the names of data members, which are accessible from objects belonging to class Author.
ii. Write the names of all the member functions which are accessible from objects belonging to class Branch.
iii. Write the names of all the members which are accessible from member functions of class Author.
iv. How many bytes will be required by an object belonging to class Author?
Q1: Consider the following declarations and answer the question given below :
class Vehicle
{
private:
int wheels;
protected :
int passenger:
public :
void inputdata(int, int);
void outputdata();
};

class Heavyvehicle : protected Vehicle
{
int diesel_petrol;
protected :
int load;
public:
void readdata(int, int);
void writedata();
};

class Bus : private Heavyvehicle
{
char make[20];
public :
void fetchdata(char);
void displaydata();
};

(i) Name the base class and derived class of the class Heavyvehicle.
(ii) Name the data member(s) that can be accessed from function displaydata().
(iii) Name the data member's that can be accessed by an object of Bus class.
(iv) Is the member function outputdata() accessible to the objects of Heavyvehicle class.
Q1: Consider the following declarations and answer the question given below :
class Vehicle
{
private:
int wheels;
protected :
int passenger:
public :
void inputdata(int, int);
void outputdata();
};

class Heavyvehicle : protected Vehicle
{
int diesel_petrol;
protected :
int load;
public:
void readdata(int, int);
void writedata();
};

class Bus : private Heavyvehicle
{
char make[20];
public :
void fetchdata(char);
void displaydata();
};

(i) Name the base class and derived class of the class Heavyvehicle.
(ii) Name the data member(s) that can be accessed from function displaydata().
(iii) Name the data member's that can be accessed by an object of Bus class.
(iv) Is the member function outputdata() accessible to the objects of Heavyvehicle class.
Q2: Answer the questions (i) and (iii) after going through the following class:
class Seminar
{
int time;
public:
Seminar() //Function 1
{
time = 30;
cout << "Seminar starts now" << endl;
}
void lecture() //Function 2
{
cout << "Lectures in the seminar on" << endl;
}
Seminar(int duration) //Function 3
{
time = duration;
cout << "Seminar starts now" << endl;
}
~Seminar() //Function 4
{
cout << "Thanks" << endl;
}
};
i. Write statements in C++ that would execute Function 1 and Function 3 of class Seminar.
ii. In Object Oriented Programming, what is Function 4 referred as and when does it get invoked/called?
iii. In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3 together?

Find and display the values of both sides of the following mathematical series expression and

an absolute difference of both sides. User can input either of angles in degree 90, 60, 30 etc.

sin(x) = x - ((x^3)/3!)+((x^5)/5!)-((x^7)/7!)+((x^9)/9!)


Once the user enters the angle in degrees. Your program should do the following (Write separate

functions for a, b, c, and d)

a) LHS Result

b) RHS Result

c) Difference

d) First term, series of two terms, series of three terms, series of four terms, series of five terms.


Write C++ program: Lets create your first cipher!!! Cipher is an algorithm that you can use to encrypt and decrypt sensitive information. In an information system, sensitive information is stored in a 16-bit unsigned number, where bit-wise information is stored in following format, 9-bits are reserved for account number and 7-bits are reserved for customer ID.


15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

C C C C C C C A A A A A A A A A


a) Using bit wise operators, write a function to extract customer ID

b) Another function to extract account number.

c) Due to security concerns, you have been given a task to create a cipher. Write a function to encrypt the 16-bit number (X) using the following expression.

y = aX + b, consider a = 5 and b = 233


d) Write another function to decrypt the number and display the original number.


Write a C++ program to Find and display the values of both sides of the following mathematical series expression and an absolute difference of both sides. User can input either of angles in degree 90, 60, 30 etc.

sin(x) = x − (x^3 / 3!) + (x^5 / 5!) − (x^7 / 7!) + (x^9 / 9!)

Once the user enters the angle in degrees. Your program should do the following (Write separate functions for a, b, c, and d)

a) LHS Result

b) RHS Result

c) Difference

d) First term,

series of two terms, series of three terms, series of four terms, series of five terms.


How to display the product of numbers divisible by 4 from 4 to 50 using do while loop


The program should behave as follows. 1. The program reads an integer and stores it in a variable year of type int. 2. If the number is not between 2000 and 2100 (with both ends included), the program should warn the user and stop (this just means that no further statements are executed by the program). Otherwise, it should proceed as follows. 3. Declare a variable leapYear of type bool which will be true if the number stored in year corresponds to a leap year, and false otherwise. 4. Use a loop to compute the value of leapYear according to the year introduced by the user. Hint: keep subtracting 4 from the value stored in year until reaching a certain condition. 5. Use year and leapYear to output the following to the screen: - if year is not a leap year, for example 2010, print The year is 2010 and it's not a leap year. - if year is a leap year, for example 2020, print The year is 2020 and it's a leap year. 


create a c++ program an internet cafe has 10,500.00 income per day. compute the total income within 30 days within 4 quarters and within 1 year. the shop will pay P2599.00 for the internet, p10000.00 the electricity and p2500.00 the maintenance


LATEST TUTORIALS
APPROVED BY CLIENTS