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
BaLLatris [955]

Answer:

the control center

Explanation:

<h2><em>hope this helps :)</em></h2>

<em>please make me brainliest\</em>

3 0
2 years ago
5x + 2y = 3<br>2x + 3y = 13​
satela [25.4K]

5x+2y=3

Slope = -5.000/2.000 = -2.500

x-intercept = 3/5 = 0.60000

y-intercept = 3/2 = 1.50000

2x+3y=13

Slope = -1.333/2.000 = -0.667

x-intercept = 13/2 = 6.50000

y-intercept = 13/3 = 4.33333

5 0
2 years ago
Role of computers in everyday life​
Simora [160]

Answer:

In modern word everything around us like GPS, ATM machines, cell phones, petrol pumps, portable play stations and all other modern devices use computer controlling units to conduct their featured operations. Surely computers have very elaborated role in daily day life of humans.

Explanation:

hope it helps thxs

8 0
3 years ago
La sección de lectores de un diario de la ciudad impone como única restricción para la publicación de las cartas, que el texto d
kap26 [50]

Answer:

El tamaño de un archivo .txt que contenga esa cantidad de texto será de 1.46 KB.

Explanation:

Se entiende que todo caracter informático posee un tamaño de 1 byte, con lo cual en total el texto no puede superar los 1,500 bytes de tamaño.

Ahora bien, un kilobyte es una unidad de medida informática superior, que se compone de 1,024. Por lo tanto, dado que 1,500 - 1,024 es igual a 474, el tamaño del archivo será de 1 KB y 474 bytes. Así, para calcular el tamaño total del archivo en KB, se debe realizar el siguiente cálculo:

1,024 = 1

474 = X

((474 x 1) / 1,024) = X

0.46 = X

Así, el tamaño de un archivo .txt que contenga esa cantidad de texto será de 1.46 KB.

4 0
3 years ago
Where do i go to find questions to answer<br> 13 points if you can help me PLz
Vesnalui [34]

Answer:

if you are on a phone there should be a Answer tab at the bottom in the middle next to influence but if you are on a computer go to the Brainly home page and scroll down to the bottom (not all the way) and there should be some questions to answer

7 0
2 years ago
Other questions:
  • What is the minimum number of bits you need to encode the 26 letters of the alphabet plus a space?Pace?
    11·1 answer
  • The family size bottle of sunscreen holds 121212 fluid ounces (\text{fl oz})(fl oz)(, start text, f, l, space, o, z, end text, )
    12·1 answer
  • List two ways that search engines and electronic databases are similar and three ways that search engines and electronic databas
    13·2 answers
  • There are six different sequences for the three approval tasks: check inventory; check credit; check special terms.
    5·1 answer
  • Which can be used to plan a program?
    13·2 answers
  • Write a Java class with the following methods: getArray(int numStrings) is an instance method that takes command line input (use
    11·1 answer
  • The technology dealing with robots is called
    6·1 answer
  • Now the y0utube home screen is gone
    13·2 answers
  • The auxiliary device used to store large volume of data and program for future is called​
    10·1 answer
  • Which area located at the top of the word screen includes home , insert , and page layout ?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!