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 & Filtering

Given two polynomials A and B, write a program that adds the given two polynomials A and B.Input


The first line contains a single integer M.

Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.

After that next line contains a single integer N.

Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.Output


Print the addition of polynomials A and B.

The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.

If co-efficient is zero then don't print the term.

If the term with highest degree is negative, the term should be represented as -Cix^Pi.

For the term where power is 1 represent it as C1x instead of C1x^1.




if sum of polynimials is zero, the output will be "0"



Write a program that reads all the match outcomes and summarizes the information of all the matches.

Points are given to the teams based on the outcome of the match.

A win earns a team 3 points. A draw earns 1. A loss earns 0.

The following information is expected:

MP: Matches Played

W: Matches Won

D: Matches Drawn (Tied)

L: Matches Lost

P: Points


The team information should be displayed in descending order of points.Input


The first line contains a single integer N, denoting the total no. of matches played.

The following N lines contain outcomes of N matches.

Each of those lines has information on the teams (T1, T2) which played and the outcome (O) in format T1;T2;O.

The outcome (O) is one of 'win', 'loss', 'draw' and refers to the first team listed.

See Sample Input/Output for better understanding.

The team name may contain spaces.





if input is zero ,the output will be "no output"


Write the definition for a class called Rectangle that has floating point data members

length and width. The class has the following member functions:

void setlength(float)r

void setwidth(float)

float perimeter()

float area()

void show()

int sameArea(Rectangle) that has one parameter of type Rectangle. sameArea returns 1 if the

two Rectangles have the same area, and returns 0 if they don't.

1. Write the definitions for each of the above member functions.

2. Write main function to create two rectangle objects. Set the length and width of the first

rectangle to 5 and 2.5. Set the length and width of the second rectangle to 5 and 18.9. Display

each rectangle and its area and perimeter.


3. Check whether the two Rectangles have the same area and print a message indicating the result.

Set the length and width of the first rectangle to 15 and 6.3. Display each Rectangle and its area

and perimeter again. Again, check whether the two Rectangles have the same area and print a

message indicating the result.


Consider the definition of the following class:

class Sample

{

private:

int x;

double y;

public :

Sample(); //Constructor 1

Sample(int); //Constructor 2

Sample(int, int); //Constructor 3

Sample(int, double); //Constructor 4

};

i. Write the definition of the constructor 1 so that the private member variables are initialized to

0.

ii. Write the definition of the constructor 2 so that the private member variable x is initialized

according to the value of the parameter, and the private member variable y is initialized to 0.

iii. Write the definition of the constructors 3 and 4 so that the private

member variables are initialized according to the values of the parameters.


Answer the questions (i) and (ii) after going through the following class:

class Test

{

char paper[20];

int marks;

public:

Test () // Function 1

{

strcpy (paper, "Computer");


r

marks = 0;

}

Test (char p[]) // Function 2

{

strcpy(paper, p);

marks = 0;

}

Test (int m) // Function 3

{

strcpy(paper,"Computer");

marks = m;

}

Test (char p[], int m) // Function 4

{

strcpy (paper, p);

marks = m;

}

};

i. Write statements in C++ that would execute Function 1, Function 2, Function 3 and Function 4

of class Test.

ii. Which feature of Object Oriented Programming is demonstrated using Function 1, Function 2,

Function 3 and Function 4 together in the above class Test?


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?


Write the definition for a class called complex that has floating point data members for

storing real and imaginary parts. The class has the following member functions:

void set(float, float) to set the specified value in object

void disp() to display complex number object

complex sum(complex) to sum two complex numbers & return complex number


1. Write the definitions for each of the above member functions.

2. Write main function to create three complex number objects. Set the value in two objects and

call sum() to calculate sum and assign it in third object. Display all complex numbers.

Note: For user understanding purposes you should write comment with each line of code.


Define a class batsman with the following specifications: Note for user understanding purposes

you should write comment with each line of code.

Private members:

bcode 4 digits code number

bname 20 characters

innings, notout, runs integer type

batavg it is calculated according to the formula –

batavg =runs/(innings-notout)

calcavg() Function to compute batavg

Public members:

readdata() Function to accept value from bcode, name, innings, notout and invoke

the function calcavg()

displaydata() Function to display the data members on the screen.


Define a class student with the following specification. Note for user understanding purposes you

should write comment with each line of code.

Private members of class student

admno integer

sname 20 character

eng. math, science float

total float

ctotal() a function to calculate eng + math + science with float return type.


Public member function of class student

Takedata() Function to accept values for admno, sname, eng, science and invoke

ctotal() to calculate total.

Showdata() Function to display all the data members on the screen.


Create a class named Course_Details that will contain get and set methods for the course name,

student numbers and lecturer. In the Course_Details class include a method called Assign Venue

that will randomly generate a Venue/Class for the course. Venues can be from 1 to 3 only. Your

main class must include a static method to handle the printing of the course report.


LATEST TUTORIALS
APPROVED BY CLIENTS