Question

[C++ Language] Give example of a void type and a double type function. Also show how...

[C++ Language] Give example of a void type and a double type function. Also show how they work in it

0 0
Add a comment Improve this question Transcribed image text
Answer #1

void type function returns no value . Here is an example

void printMessage(){

cout<<"Hello World!";

}

The function printMessage() prints the message "Hello World", it does not return any value and so the return type is mentioned as void

=============================================================================

double type function returns a value whose data type is double. Here is an example :

double average(int a, int b, int c){

return (a+b+c)/3.0;

}

The function average() takes in 3 arguments of int type, the function computes the average of the 3 numbers and return the average value as a double.

============================================================================

Hope this helps. Let me know for any questions or help.

Add a comment
Know the answer?
Add Answer to:
[C++ Language] Give example of a void type and a double type function. Also show how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Give example of a void type and a double type function. Also show how they work.

    Give example of a void type and a double type function. Also show how they work.

  • Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate)...

    Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate) Question 1 options: Python A C-based language FORTRAN COBOL Question 2 One of my favorite quotes from Jeanette Wind is "Computational thinking is using abstraction and decomposition when attacking a large complex task or designing a large complex system." This supports using _____________ when developing programs. Question 2 options: Repetition structures Assignment statements Selection structures Functions Question 3 The following assignment statement exhibits which...

  • In C++: Implement a function void root (double a, double b, double c, double& x1, double&...

    In C++: Implement a function void root (double a, double b, double c, double& x1, double& x2) which assigns two solutions of quadratic equation aa bc0 to variables x1 and x2 Where a, b and c are real numbers. The 2 solutions are: Write the pre-condition and post-condition for two functions above (in questions 1 and 2). 2a

  • If void * is a pointer to void is a "generic" pointer type, and a void...

    If void * is a pointer to void is a "generic" pointer type, and a void * can be converted to any other pointer type * without an explicit cast, why in the ,myarrcopy function the malloc is created like char and not like void? if we are going to work with different type of arrays? Here is de program: *This is a function that make a copy of any given array. * We then use this function make a...

  • c++ • return type function name (parameter); • Ex: int Joe(int, int); • Ex: void gg(int,...

    c++ • return type function name (parameter); • Ex: int Joe(int, int); • Ex: void gg(int, float); • Ex: double Two_sol(double, double, double): 2. fC → function call • Ex: cout << Joe(); • Ex: Joe(5, 0); 3. fD → function definition return type function name of STATEMENT(S) return function name: **program84 Void functions to print "Welcome to the world of functions!" programs. To print the sum and product of 2 numbers using functions w/out parameters. program86: to print the...

  • c++ language 1) Create a function that prints a greeting when called with a name such...

    c++ language 1) Create a function that prints a greeting when called with a name such as greeting ("Elona") 2) Create a function that squares a double number and returns the result as a double. 3) Create a function that takes 5 int numbers and returns the average as a float 4) Create a single function that gives a greeting, calculates the average of 5 grades but does not return a value. Hint: Use return type void and a string...

  • C++ class derivedFromTemp: public temp; {public:    void print();    void setZ(double);    double getZ();   ...

    C++ class derivedFromTemp: public temp; {public:    void print();    void setZ(double);    double getZ();    double power() const; //return X to power of Z assume getX and setX in temp class.       drivedFromTemp();    derivedFromTemp (string, double, double); Private:    double z; }; A. Correct errors, if any, after that write difinition of the member function of the class derivedFromTemp.

  • programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /*...

    programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /* prototype */ void main() { int a, b, c; void fun1(void) { int b, c, d; void fun2 (void) { int c, d, e; void fun3(void) { int d, e, f, Assuming that dynamic scoping is used, what variables are visible during execution of the last function called in following calling sequence: main calls...

  • can anyone help me with this 6 function as c++ language. It is not required to...

    can anyone help me with this 6 function as c++ language. It is not required to return in main. In addition to these 10 functions, you'll have 6 more functions void incDouble(double al], unsigned els); incDouble's job is to sort the array so that the values are in increasing order void decDouble(double al], unsigned els); decDouble's job is to sort the array so that the values are in decreasing order void inc Vec(vector<double> & v); incVec's job is to sort...

  • Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[],...

    Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[], char destination[], int n); This function copies string source to string destination. Parameter n represents the size of array destination. If the latter array is not sufficiently large to hold the whole source string then only the prefix of the string which has room in the latter array should be copied. Note that after copying, the null character should also be included to mark...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT