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
LuckyWell [14K]
3 years ago
15

Define a function called hasRealSolution that takes three parameters containing integer values: a, b, and c. If "b squared" minu

s 4ac is negative, the function returns False otherwise, it returns True.
Computers and Technology
1 answer:
sukhopar [10]3 years ago
6 0

Answer:

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 <iostream>  // 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<<x; // display the return value

  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.

You might be interested in
A(n) ____ consists of a series of related instructions, organized for a common purpose, that tells the computer what tasks to pe
yarga [219]

Answer:

The correct answer is "Program".  

Explanation:

Program is the collection of statement or instruction which is developed for creating any software or any purpose. The program is implemented or executed by a computer to perform a particular task.The particular programmer always writes an instruction to develop a program.

Program are always organized for the common purpose, that specifies the computer what tasks to perform as well as how to perform that particular task for example if programmer develops a program of calculator then it should be only used for the calculation purpose.

7 0
3 years ago
A well-diversified portfolio needs about 20-25 stocks from different categories is this True or False?
borishaifa [10]

Usually they hold 15-20 as the minimum of the portfolios

So I would say True

3 0
3 years ago
Read 2 more answers
How to play Drinkopoly game?
professor190 [17]
Answer:
Never heard of that lol
3 0
2 years ago
compare a 4 core processor 1.3ghz 8 megabytes 16ram and 2 terabyte hard drive to a 2 core 3.9 ghz 2 megabyte cache 4gb ram and 2
deff fn [24]

Answer:

answer is in the question

Explanation:

4 0
2 years ago
Design a program for the Hollywood Movie Rating Guide, which can be installed in a kiosk in theaters. Each theater patron enters
ehidna [41]

Answer:

The program in cpp is given below.

#include <iostream>

using namespace std;

int main()

{

   //variables declared to hold sum, count and average of movie ratings

   int sum=0;

   int count=0;

   int rating;

   double avg;

   //audience is prompted to enter ratings

   do{

       std::cout << "Enter the rating (0 to 4): ";

       cin>>rating;

       if(rating>4)

           std::cout << "Invalid rating. Please enter correct rating again." << std::endl;

       if(rating>=0 && rating<=4)

       {

           sum=sum+rating;

           count++;

       }

       if(rating<0)

           break;

   }while(rating>=0);

   //average rating is computed

   avg=sum/count;

   std::cout << "The average rating for the movie is " << avg << std::endl;  

   return 0;

}

OUTPUT

Enter the rating (0 to 4): 1

Enter the rating (0 to 4): 2

Enter the rating (0 to 4): 0

Enter the rating (0 to 4): 5

Invalid rating. Please enter correct rating again.

Enter the rating (0 to 4): 1

Enter the rating (0 to 4): -1

The average rating for the movie is 1

Explanation:

1. Variables are declared to hold the rating, count of rating, sum of all ratings and average of all the user entered ratings.

2. The variables for sum and count are initialized to 0.

3. Inside do-while loop, user is prompted to enter the rating for the movie.

4. In case the user enters a rating which is out of range, the user is prompted again to enter a rating anywhere from 0 to 4.

5. The loop executes until a negative number is entered.

6. Inside the loop, the running total sum of all the valid ratings is computed and the count variable is incremented by 1 for each valid rating.

7. Outside the loop, the average is computed by dividing the total rating by count of ratings.

8. The average rating is then displayed to the console.

9. The program is written in cpp due to simplicity since all the code is written inside main().

6 0
3 years ago
Other questions:
  • Web storage stores data in the browser in
    5·1 answer
  • Laura has identified the job she wants, the skills needed for the position, and the areas she needs to improve in order to get i
    10·1 answer
  • What is wrong, logically, with the following code? if (x &gt; 10) System.out.println("Large"); else if (x &gt; 6 &amp;&amp; x &l
    11·1 answer
  • Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished
    14·2 answers
  • Current versions of windows support file names up to ________ characters long
    5·1 answer
  • Why do we allow electronic instruments to warm-up before use?
    11·1 answer
  • Describe the different
    12·1 answer
  • (Please answer both parts, please)
    8·2 answers
  • ________________, _______________ and ___________ are what you see when you open Excel
    14·2 answers
  • I'm having trouble with an assignment of mine. I'm making a text based adventure game for extra credit in my class and I'm stuck
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!