Ask Question
7 September, 11:34

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.

+5
Answers (1)
  1. 7 September, 11:55
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers