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
gavmur [86]
3 years ago
10

The following program results in a compiler error. Why? int FindMin(int a, int b) { int min; if (a < b) { min = a; } else { m

in = b; } return min; } int main() { int x; int y; cin >> x; cin >> y; min = FindMin(x,y); cout << "The smaller number is: " << min << endl; return 0; }
Computers and Technology
1 answer:
Mila [183]3 years ago
7 0

Answer:

The answer is "Variable min is defined in the "FindMin()" method, but is used in the main method".

Explanation:

Following are the correct code to the given question:

#include <iostream>//header file

using namespace std;

int FindMin(int a, int b) //defining a method FindMin that takes two integer parameters

{

   int min; //defining integer variable

   if (a < b) //use if to check a value less than b

   {

       min = a; //holding smallest value in min

   }

   else //defining else block

   {

       min = b;//holding smallest value in min

   }

   return min; //return min value

}

int main() //defining main method

{

   int x,y,min; //defining integer variable

   cin >> x; //input value

   cin >> y; //input value

   min = FindMin(x,y); //holding method return value in min variable

   cout<<"The smaller number is: "<<min<< endl; //print method value with message

   return 0;

}

Output:

Please find the attached file.

In the code, a method "FindMin" is defined that takes two integer parameters "a,b" and inside the method, an integer variable "min" is declared that uses a conditional statement that checks the smallest value that store in the min variable and return its value.

In the main method, three integer variable is declared in which two is used for hold value from user-end pass into the method and store its return value in min variable and print value with the message.

You might be interested in
CHALLENGE ACTIVITY
julia-pushkina [17]

Answer:

avg_owls=0.0

num_owls_zooA = int(input())

num_owls_zooB = int(input())

num_owls_zooC = int(input())

num_zoos = 3

avg_owls = (num_owls_zooA + num_owls_zooB + num_owls_zooC) / num_zoos

print('Average owls per zoo:', int(avg_owls))

Explanation:

There is a problem while you are trying the calculate the average owls per zoo.

As you may know, in order to calculate the average, you need to get the total number of owls in all the zoos, then divide it to the number of zoos. That is why you need to sum num_owls_zooA + num_owls_zooB + num_owls_zooC and divide the result by num_zoos

Be aware that the average is printed as integer value. That is why you need to cast the avg_owls to an int as int(avg_owls)

6 0
3 years ago
adding ______around calculations indicates which calculations should be performed first before following the typical order of op
Wittaler [7]
Parentheses! Hope this helped you
5 0
3 years ago
Develop a multithreaded app that can find the integer in the range 1 to 10000 that has the largest number of divisors. It should
skelet666 [1.2K]

Answer:

its not letting me Write out the code so here are screenshots

Explanation:

5 0
4 years ago
The home keys on the numeric keypad are?
Eva8 [605]
4, 5 , 6 , and plus key
456+
5 0
3 years ago
Read 2 more answers
What happens when a computer gets a virus?
Volgvan
You will start to get ad pop-ups like crazy, and your computer will be a lot slower. I'd recommend that you be careful downloading things, make sure it's the right thing you're downloading. Some people make false websites. Also the best thing to do is get a usb drive and store everything you want to keep and reset your computer to factory in your settings.
3 0
3 years ago
Read 2 more answers
Other questions:
  • In the simulation, player 2 will always play according to the same strategy. The number of coins player 2 spends is based on wha
    6·1 answer
  • Where is the brightness and contrast changed at?
    10·2 answers
  • Write a C function (NOT A COMPLETE PROGRAM)which takes three parameters which are the cost for an item in a grocery store, the q
    12·1 answer
  • The following processes are being scheduled using a preemptive, round-robin scheduling algorithm. Each process is assigned a num
    6·1 answer
  • Select the correct answer. Which of these statements is an explorer most likely to make?​
    6·1 answer
  • Which statement is most likely to be true about a computer network?
    12·2 answers
  • HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP!!!
    12·1 answer
  • how is a two-dimensional array different from a traditional one dimensional array? From an ArrayList?
    6·1 answer
  • Diane changes the size of an image with the format picture pane and keeps the original ratio of height to width of the object. W
    8·1 answer
  • How do you delete questions you asked?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!