Ask Question
8 September, 14:32

Define a function called hasRealSolution that takes three parameters containing integer values: a, b, and c. If "b squared" minus 4ac is negative, the function returns False otherwise, it returns True.

+1
Answers (1)
  1. 8 September, 17:59
    0
    Following are the function in C+ + Programming language

    bool hasRealSolution (int a, int b, int c) / / function definition

    {

    if ((b*b) - (4*a*c) <0) / / check condition

    return false;

    else

    return true;

    }

    Explanation:

    Following are the program of this question

    #include / / header file

    using namespace std; / / namespace

    bool hasRealSolution (int a, int b, int c); / / prototype

    bool hasRealSolution (int a, int b, int c) / / function definition

    {

    if ((b*b) - (4*a*c) <0) / / check condition

    return false;

    else

    return true;

    }

    int main () / / main function

    {

    bool x=hasRealSolution (1,2,4); / / calling

    cout<
    return 0;

    }

    Output:

    0

    Following are the description of code:

    We declared a function i. e "hasRealSolution " of "bool" type. In this function there are three parameter is pass "a","b" and "c" of "int "type. In the if block we check the condition i. e if "b squared" minus 4ac is negative then it returns the false bool value otherwise it returns the true bool value. In the main function we call the function "hasRealSolution " by passing three integer values into that function and store their value in variable "x" of the bool type. Finally we print the value x in the main function.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Define a function called hasRealSolution that takes three parameters containing integer values: a, b, and c. If "b squared" minus 4ac is ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers