1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
uysha [10]
3 years ago
5

) Write a complete C++ program in one file which takes a double value from the user, cubes it, and prints the result. Your progr

am must use a function which takes a parameter for the value to be cubed and returns the result by value. The function may not print anything or read anything directly from the user (i.e. no cin/cout in the function). Hint: n cubed is defined as n*n*n. Upload as cubeValue.cpp. (8 pts
Computers and Technology
1 answer:
Jet001 [13]3 years ago
6 0

Answer:

The cpp program is given below.

#include <stdio.h>

#include <iostream>

using namespace std;

//function for cubing declared

double cubeValue(double n);

int main()

{

   //variable to hold user input

   double num;

   std::cout <<"Enter a number to be cubed: ";

   cin>>num;

   //variable to hold cube

   double cube;

   //function returns cube

   cube = cubeValue(num);

   std::cout <<"The cube of " <<num <<" is "<<cube <<std::endl;

   return 0;

}

//function to compute cube of the given parameter

//function definition

double cubeValue(double n)

{

   double d;

   d = n*n*n;

   return d;

}

OUTPUT

Enter a number to be cubed: 3.4

The cube of 3.4 is 39.304

Explanation:

1. The function for cubing is declared in the beginning of the program. The function has double return type as well as takes a double parameter. The function is defined after the main() method. The function only returns the cube of the double parameter passed to it.

double cubeValue(double n);

2. Inside main(), user input is taken for the number whose cube is to be computed.

3. The user input is taken in variable, num.

4. Another double variable, cube, is declared.

5. The method, cubeValue(), is called by passing variable num as parameter.

6. The value returned by the method, cubeValue() is assigned to the variable, cube.

cube = cubeValue(num);

7. The cube is displayed to the user using cout.

8. The program ends with return statement.

return 0;

The return statement assures successful execution of the program.

The program may not contain any syntax errors but contain logic errors which is indicated by the error message. The error message is displayed in red with return value -1.

9. The program is saved as cubeValue.cpp.

10. The method, cubeValue(), does not takes user input and does not prints any message.

11. The code is not written inside the class. The program contains only two methods.

12. The program can be tested for both integer and double values.

13. The program is written in cpp as per the requirements.

You might be interested in
2. (8 points) When creating the Academic Database, there were several instances of data
Bad White [126]

Answer:

See explaination

Explanation:

An Academic Database deals with the information pertaining to the records of students of an institute. The various fields which can be associated with a student are Name, Unique Identification Number, Marks in various subjects, Grades, Courses Taken and so on. Most of the fields mentioned above have some or other form of validation that is required for the DB to be consistent and follow the basic properties of a database.

One field where range validation can be used is MARKS. In the marks field, the range of marks will be say 0 to 100 and anything below 0 or above 100 must be reported to the database administrator. Another field where we can apply a range validation is AGE in which the range of age allowed could greater than say 10, if it is a college and maximum age could be say 60. Thus, the range check on the AGE field is 10 to 60.

One field where choice validation can be used is GENDER. In the gender field, there could be multiple choices like Male, Female and Others. Thus, out of the available choices we have to select only the available choice and only one choice must be selected where we can apply choice validation. Another field is COURSE, where we can have a list of courses a student can opt for and out of the available courses can select one.

Thus, there are multiple fields where we can apply various types of validation and it is important to explore the area for which the DB has been created understanding all the scenarios and attributes of the problems that are associated with that area.

8 0
4 years ago
The hardware components of a computer system interact with each other by using which of the following?
Inga [223]
B it is b..............................................
6 0
4 years ago
Read 2 more answers
How many total channels are available in the United States for wireless LAN use in the unlicensed 2.4ghz ism band ?
Usimov [2.4K]
Answer: 14 channels are available in the unlicensed 2.4 GHz ISM band.
3 0
3 years ago
You are a solutions engineer working for a large communications company that is migrating its existing server estate to AWS. You
erik [133]

Answer:

4 subnets

Explanation:

According to the specifications provided, it seems that you would need a total of 4 subnets for the entire server structure. This is because each web server needs 1 public subnet and each database needs one private subnet. If there are a total of 2 web servers and 2 database servers then each one will ultimately have 2 subnets meaning a total of 4 subnets. These would be 2 public subnets and 2 private subnets for the different availability zones, which would allow the server structure to maintain high availability.

4 0
3 years ago
Which of the following is not a network category based on the geographic dispersion of network components?
barxatty [35]

Answer:B) Wide-Area Network (WAN)

Explanation: WAN(Wide area network)is the network which constitutes a large geographical region.This network consist of the small network unit as well as large network connections.This network does not have the geographic dispersion of the components of networks.

WAN works in geographic region for the dispersion between any two locations. Other options are incorrect because they connect the network components geographically. Thus the correct option is option(B).

7 0
4 years ago
Other questions:
  • Which are examples of embedded systems? Choose two answers.
    15·1 answer
  • Which operator is used for quotient division in java​
    6·1 answer
  • What age group is experiencing the most growth in social media
    13·1 answer
  • A construction company has an online system that tracks all of the status and progress of their projects. The system is hosted i
    10·1 answer
  • Ethics in businesses and organizations are made up of a set of moral principles that guide the organizations. Discuss how good w
    8·1 answer
  • The TCP/IP ____ layer, sometimes called the Internet layer, is roughly equivalent to OSI's network layer.
    7·1 answer
  • In the circuit shown in the figure above, what will happen when switches S1 and S3 are both closed? 
    8·1 answer
  • Need help with Brainly!! Thanks in advance for sharing your thoughts or answering any of my questions on this. [][] Firstly, Bra
    14·1 answer
  • Take points for free who are new and enjoye them
    9·2 answers
  • State two differences between a mouse pointer and a mouse cursor​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!