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
Nat2105 [25]
3 years ago
14

. Write a function definition as follows: it returns the C++ form of a Boolean value, its function identifier is anyTwoTheSame,

it has three formal parameters which all are floating-point values, and the body of the function returns true if any two of the parameters are equal, otherwise it returns false. I recommend using short, simple identifiers for the three formal parameters.
Computers and Technology
1 answer:
Paraphin [41]3 years ago
3 0

Answer:

The c++ code to implement the Boolean function is given. The function definition is shown.

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

Explanation:

This function accepts three floating point numbers and returns true if any two numbers are equal else returns false.

The program below shows the implementation of this method.

#include <iostream>

using namespace std;

bool anyTwoTheSame(float a, float b, float c);

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

int main() {    

   float one=12.34, two=56.78, three=90.1;    

   cout<<"Two numbers are same : " <<anyTwoTheSame(one, two, three);

}

OUTPUT

Two numbers are same : 0

The method is first declared.

bool anyTwoTheSame(float a, float b, float c);

Next step is method definition which shows what the function is supposed to do. The test to check equality of two numbers is implemented as shown.

bool same = false;    

if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;  

This is the simplest test which can be programmed.

If the numbers are not same, the Boolean variable, same, remains initialized to false.

This function is then called in main method.

No user input is taken as this is not specified in the question.

The three floating variables are declared and initialized inside the main. The values are put inside the program and not taken from the user.

The output shows either 0 or 1. 0 represents false and 1 represents true.

This program can be tested for different values of floating variables.

You might be interested in
1. Customizable diagrams, including List, Process, and Cycle diagrams, are built into Word and can be found in
nikdorinn [45]

1 A. SmartArt.


2 C. He needs to check to see if they are compatible with Word.


3 A. It has many different style samples that can be applied., and D. It is found under the Home tab.

4 0
3 years ago
Read 2 more answers
Stacey wants to change her document to landscape view instead of portrait. Jesse wants to change the scale of his document. Whic
sweet-ann [11.9K]

Answer:

C) Stacey and Jesse can both look under Page Layout or under File and select Print.

Explanation:

5 0
3 years ago
Nina wants to create a digital backup of her holiday videos to view later. What two of these devices could she use?
mel-nik [20]
Memory card, external hard drive
7 0
4 years ago
Read 2 more answers
in a mechanism when the input goes from a small gear to an output which is a larger gear will the speed increase or decrease?
Ksenya-84 [330]
Speed decreases, power increases
7 0
4 years ago
What is collaboration
Scorpion4ik [409]

Answer:

the action of working with someone to produce or create something.

Collaboration is the process of two or more people, entities or organizations working together to complete a task or achieve a goal. Collaboration is similar to cooperation. Most collaboration requires leadership, although the form of leadership can be social within a decentralized and egalitarian group.

4 0
3 years ago
Other questions:
  • A video game character prefers to take enemies on from a distance. What skills might such a character have?
    11·2 answers
  • The entrance facility is the place where the connection to a WAN is located. It is basically the point where the LAN begins and
    9·1 answer
  • in a management information system, the quality of information is determined by its usefulness to users, and its usefulness dete
    8·1 answer
  • The date your Science project is due should be recorded on a daily organizer. Please select the best answer from the choices pro
    14·2 answers
  • Line installers must complete a four-year university degree program in order to be hired.
    5·2 answers
  • Raw materials have two basic types what are the 2?
    11·2 answers
  • _____ have networked and texted all of their lives with smartphones, tablets, and high-speed Internet.
    8·1 answer
  • if you want to build a smart-glove that responds based on the direction and speed a user moves their hand, what sensor should yo
    6·1 answer
  • 1.What is the output of the following program? [10 Marks]namespace ConsoleApp1{class Program{static void Main(string[] args){int
    13·1 answer
  • 1.Which thematic group uses technology to direct the behavior of dynamical systems, ensuring that they behave in a predictable m
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!