Write a function called power that takes a double value for

Assignment Help C/C++ Programming
Reference no: EM131097376

Program :-1

Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power () that takes a double value for n and an int value for p and returns the result as double value. Use a default argument of 2for p, so that if this argument is omitted the number will be squared. Write a main () function That gets values from the user to test this function.

Program :- 2

A point on the two dimensional plane can be represented by two numbers: an X coordinate and a Y coordinate. Foe example (4,5) represents a point to the right of the origin along with the X axis and 5 units up the Y-axis. The sum of two points can be defined as a new point whose X coordinate is the sum of the X coordinates of the points and whose Y coordinate is the sum of their Y coordinates.

Write a program that uses a structure called point to model a point. Define three points and have the user input values to two of them. Than set the third point equal to the sum of the other two and display the value of the new point. Interaction with the program might look like this:

Enter coordinates for p1: 3  4
Enter coordinates for p2: 5  7
Coordinates of p1+p2 are:8,11

Program :- 3

Create the equivalent of a four function calculator. The program should request the user to enter a number an operator and another number. It should then carry out the specified arithmetical operation: adding, subtracting, multiplying or dividing the two numbers (it should use a switch statement to select the operation). Finally it should display the result.

When it finishes the calculation, the program should ask if the user wants to do another calculation. The response can be 'Y' or 'N'. some sample interaction with the program might look like this.

Enter first number, operator, and second number.10/3
Answer=3.333333
Do another (Y/N)? Y

Enter first number, operator, and second number 12+100
Answer=112
Do another (Y/N)? N

Program :-4

A phone number such as (212) 767-8900 can be thought of as having three  parts: the area code (212), the exchange (767) and the number (8900). Write a program that uses a structure to store these three parts of a phone number separately. Call the structure phone. Create two structure variables of type phone. Initialize one and have the user input a number for the other one. Then display both numbers. The interchange might look like this:
Enter your area code, exchange and number; 415 555 1212

My number is (212) 767-8900
Your number is (415) 555-1212

Program :- 5

Create two classes DM and DB which store the value of distances. DM stores distances in meters and centimeters and DB in feet and inches. Write a program that can read values for the class objects and add one object of DM with another object of DB.

Use a friend function to carry out the additional operation. The object that stores the result may be a DM object or DB object depending on the units in which the results are required. The display should be in the format of feet and inches or meters and centimeters depending on the object on display.

Program 6

Create a class Rational which represents a numerical value by two double values-NUMERATOR & DENOMINATOR .Include the following Public member Functions:

  • Constructor With no Arguments
  • Constructor with two arguments
  • Void reduce() tha reduces the rational nuber by eliminating the hightest commom factor between the numeratorand denominator
  • Overload +operator to add two rational number.
  • Overload >>operator to enable input through cin.
  • Overload << operator to enable output through cout

Write a main()  to test all thje functions in the class.

Program :-7

Consider the following class definition 

Class father
{
  Protected: 
     int age;
  public:
     father (int x) {age=x;}

        virtual void iam ()
      {
         Cout<<"I AM THE FATHER, my age is:"<age<<endl;}
};

Derive the two classes son and daughter from the above class and for each, define iam() to write our similar but appropriate messages. you should also define suitable constructors for these classes.

Now write a main() that creates objects of the three and then calls iam() for them. Declare pointer and in each case call iam() through the pointer to demonstrate polymorphism in action.

Reference no: EM131097376

Questions Cloud

Realizing the importance of answering question : The first objective listed for this chapter is: "Realizing the importance of answering the question 'Why do I work?'" As a follow up question the text asks: "How do you define "success" in your work?" (p. 144) So, why do you work?
How the incremental method relates to the branch method : MIDTERM EXAM - PAD 506: PUBLIC BUDGETING AND FINANCE. Charles E. Lindblom, "The Science Muddling Through," Public Administration Review 19 (Spring 1959): 79-88. Analyze how the incremental method relates to the branch method
Realizing the importance of answering question : The first objective listed for this chapter is: "Realizing the importance of answering the question 'Why do I work?'" As a follow up question the text asks: "How do you define "success" in your work?" (p. 144) So, why do you work?
Find the equilibrium price-quantities and profits : Consider two Bertrand competitors in the market for brie, Franc ¸ois and Babette. The cheeses of Fran ¸cois and Babette are differentiated, with the demand for Fran ¸cois’ cheese given by qF = 30 − pF + pB , Find the equilibrium price, quantities, an..
Write a function called power that takes a double value for : Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power () that takes a double value for n and an int value for p and returns the result as double value. Use a default argument of 2for p, so that ..
What is the concert hall producer surplus : Suppose that a concert hall faces the following demand curve for its evening shows: QE =40−.8P and the following demand for its afternoon shows: QA =24−.8P where Q is the number of tickets in thousands and P is the price of a ticket in dollars. What ..
Preferred choice wayne center for nursing : Enter the 10468 zip code in the box asking for a location or zipcode and select one of the Bronx nursing homes that will be listed.  Review all aspect (staffing, survey, quality measures) and write a paragraph to summarize what you learned from vi..
What will be its profit-maximizing price-producer surplus : Suppose Netflix’s representative customer’s demand curve in the market for DVD rentals is Q = 20 − 10P, where Q is the number of DVDs rented per month and P is in dollars per DVD. If Netflix charges a single price per DVD regardless of how many DVDs ..
Find the long-run equilibrium price in the market : Assume a perfectly competitive industry. Each firm in the industry faces a long-run total cost such that LTC=14000q−80q2+q3 and LMC=14000−160q+3q2. Find the long-run quantity produced by each firm. Find the long-run equilibrium price in the market.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  C program that displays the sales tax amount for each store

It will be necessary for you to access Service Request: ¿SR-kf-008, Tax Calculator¿ from the Virtual Organizations portal. Complete Change Request #1. Insert comments in the program to document the program internally. Attach a design flow chart to..

  Write a program that tells what coins to give out

Write a program that tells what coins to give out for any amount of change from 1 to 99 cents.

  Create a program, using at least one for loop

Create a program, using at least one For loop, that displays the Sales Amounts made in each of 4 regions (North, South, East, and West) during a three month period.

  What are the three oops principles

What are the three Oops principles, define them and What is the difference between C++ & Java?

  Implement a class address

A theater seating chart is implemented as a two-dimensional array of ticket prices like presented below. Write a program that prompts the users to pick either a seat or a price. Mark sold seats by changing the price to zero.

  Computer programming using c language lab

Computer programming using c language lab

  Square and colour of the square

A player generates two random numbers. Ex: generated number is 2 & 3 the player clicks in the 2x3 square and colour of the square should change.

  Prepare a table showing loan amount

Write a C++ program that prints a table showing loan amount, interest rate, length of loan, monthly payments, and total cost of a mortgage.

  The staffs need a program that can determine

The staffs need a program that can determine whether children have been naughty or nice. individual data files(can be any name) for each childred are available that consist of 368(365+3)integer number each.

  Write a c function for reversing circular single linked list

Let A and B be two structures of type linked list. Write a function for creating new linked list C that contains elements alternately from A and B beginning with first element of A. If you run out of the elements in one of the lists then append the r..

  Define a cpp function that has two integer inputs

Define a C++ function that has two 2 integer inputs (N) and returns a double output y, where y=∑sqrt(n+0.5)/(2n+1) n=1 the value of n s'd be positive.

  Write a c++ program to first find ''n'' fibonacci numbers

Write a C++ program to first find 'N' Fibonacci numbers and then display only the "even" Fibonacci numbers in "descending order" as output.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd