Ask Question
2 January, 19:59

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.

+2
Answers (1)
  1. 2 January, 21:04
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers