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

Show the printout of the following code:


int a = 6;


Int b = a++;


cout << a << endl;


cout << b << endl;


a = 6;


b = ++a;


cout << a << endl;


cout << b << endl;

Write a program that inputs an array of 10 integers. After inputting display the values according to user choice and take a number from user. For example if user enters 7 then display first 7 elements of array.

Write a program that incorporates both the bMoney class from Exercise 8 and the sterling


class from Exercise 11. Write conversion operators to convert between bMoney and


sterling, assuming that one pound (£1.0.0) equals fifty dollars ($50.00). This was the


approximate exchange rate in the 19th century when the British Empire was at its height


and the pounds-shillings-pence format was in use. Write a main() program that allows


the user to enter an amount in either currency and then converts it to the other currency


and displays the result. Minimize any modifications to the existing bMoney and sterling


classes.

Write a program that incorporates both the bMoney class from Exercise 8 and the sterling


class from Exercise 11. Write conversion operators to convert between bMoney and


sterling, assuming that one pound (£1.0.0) equals fifty dollars ($50.00). This was the


approximate exchange rate in the 19th century when the British Empire was at its height


and the pounds-shillings-pence format was in use. Write a main() program that allows


the user to enter an amount in either currency and then converts it to the other currency


and displays the result. Minimize any modifications to the existing bMoney and sterling


classes.

You are given an undirected tree with N nodes and the tree is rooted at node 1. Each node has an integer value A[i] associated with it represented by an array A of size N.


Also, you are given Q queries of the following type:


• uvk: Find the kth smallest value present on the simple path between node u and node v. If the number of nodes on the simple path between node u and node v is less than k, then print —1.


Input format

•  The first line contains two space-separated integers NQ denoting the number of nodes and queries respectively.

•  The second line contains N space-separated integers denoting array A.

•  Next N — 1 line contains two space-separated integers denoting the edges of the tree.

•  Next Q lines contain three space-separated integers denoting the queries.


Output format

Print Q space-separated integers denoting the answer of queries.


Constraints


1 ≤ N ≤ 4 x 104

1 ≤ Q ≤ 105

1 ≤ A[i] ≤ 109

Any number is called beautiful if it consists of 2N digits and the sum of the first N digits is equal to the sum of the last N digits. Your task is to find the count of beautiful numbers in the interval from L to R (including L and R).


Beautiful numbers do not have leading zeroes.


Input format


•  The first line contains an integer T denoting the number of test cases.

•  The first line of each test case contains two space-separated integers L and R denoting the range interval [L, R].


Output format


For each test case, print the count of beautiful numbers in a new line.


Constraints


1 T ≤ 2000001 ≤ L ≤ R ≤ 100000000
  SAMPLE INPUT                  SAMPLE OUTPUT

     1                                                                                            9

1 100

Write code using binary sort that


Finds the total number of boys and girls in class.

An electricity board charges the following rates to domestic users to

discourage large consumption of energy.


 For the first 100 units − 50 P per unit


 Beyond 100 units − 60 P per unit


If the total cost is more than Rs.250.00 then an additional surcharge of

15% is added on the difference. Define a class Electricity in which the

function Bill computes the cost. Define a derived class More_Electricity

and override Bill to add the surcharge.



sorting 5 numbers using the basics (without array)


Show the output of the following code :

double area = 5.2 ;

cout << "area " ;

cout << area ;


LATEST TUTORIALS
APPROVED BY CLIENTS