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
dalvyx [7]
2 years ago
7

Write a function float Average(int, int) that finds the mean, and then write a main program that inputs two numbers from the use

r repeatedly until the user enter “0”. You need to call the function and display the mean of two numbers in the main. C++ language only.
Computers and Technology
1 answer:
meriva2 years ago
5 0

The program illustrates the use of functions.

Functions are used to group related code segments that act as one, when called.

The program in C++ where comments are used to explain each line is as follows:

#include <iostream>

using namespace std;

//This defines the Average function

float Average(int num1, int num2){

   //This returns the average of the numbers

   return (num1+num2)/2.0;

}

//The main method begins here

int main(){

   //This declares the numbers as integer

   int num1, num2;

   //This gets input for both numbers

   cin>>num1; cin>>num2;

   //This is repeated until the user enters 0

   while(num1!=0 || num2 !=0){

       //This calls the average function, and prints the average

       cout<<Average(num1,num2)<<'\n';

       //This gets input for both numbers, again

       cin>>num1; cin>>num2;

   }

   return 0;

}

Read more about similar programs at:

brainly.com/question/17378192

You might be interested in
Which statement is true regarding Artificial Intelligence (AI)?
Effectus [21]
Data is the fundamental reason AI succeeds or fails.
This statement is true regarding Artificial Intelligence (AI)
6 0
3 years ago
Write a script that calculates the common factors between 8 and 24. To find a common factor, you can use the modulo operator (%)
AnnyKZ [126]

Answer:

  1. common = []
  2. num1 = 8
  3. num2 = 24
  4. for i in range(1, num1 + 1):
  5.    if(num1 % i == 0 and num2 % i == 0):
  6.        common.append(i)
  7. print(common)

Explanation:

The solution is written in Python 3.

Firstly create a common list to hold a list of the common factor between 8 and 24 (Line 1).

Create two variables num1, and num2 and set 8 and 24 as their values, respectively (Line 3 - 4).

Create a for loop to traverse through the number from 1 to 8 and use modulus operator to check if num1 and num2 are divisible by current i value. If so the remainder of both num1%i and num2%i  will be zero and the if block will run to append the current i value to common list (Line 6-8).

After the loop, print the common list and we shall get [1, 2, 4, 8]

8 0
3 years ago
Name at least three real-life objects that are instances of each of the following classes:
DENIUS [597]

The three real-life objects that are instances of each of the following classes are given below:

a.<u> Song:</u>

The song Believe in yourself is an instance of song class

The song Where do broken hearts go is an instance of song class.

The song Ambition is an instance of song class

b. <u>CollegeCourse</u>

The College course Engineering is an instance of College course class

The College course Accounting is an instance of College course class

The College course Medicine is an instance of College course class

c. <u>Musician:</u>

The musician Rihanna is an instance of musician class.

The musician Sean Paul is an instance of musician class.

The musician Wyclef is an instance of musician class.

Real-life objects refer to the things that are characterized together as they share common qualities. The assignment simply wants you to name examples under the categories given.

Read related link on:

brainly.com/question/16699733

7 0
2 years ago
Ideally, Internet of Things (IoT) devices have the ability to:
Stella [2.4K]

Answer:

I believe the answer would be D

8 0
3 years ago
How does the use of imagery create meaning
Contact [7]

Imagery is a feature of written and spoken language and occurs whenever someone has chosen to use language in a non-literal way.

Imagery is a way of describing something symbolically, using words to create a picture in the reader's imagination.

In the Close Reading paper you need to be able to recognise imagery and to consider how successful the imagery is at conveying to you what the writer is trying to express. Imagery frequently conveys more than just meaning. It is used to heighten the effect of language and is often an extension of word-choice. Normally an image will extend to a phrase or a few words but sometimes it will be longer. The simplest form of imagery to recognise is when something or someone is compared to something else, with the purpose of establishing some parallel between the two. Images of this kind frequently concern qualities like beauty, speed, force, power and natural and animal traits.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following can you NOT apply for at any FLHSMV office? A. Certificate of title B. License plates C. Vehicle registra
    15·2 answers
  • True or false
    7·1 answer
  • Anicius boethius invented a system that made possible the memorization and written transmission of melodies.
    9·1 answer
  • what are Include the data on usage you gather from your interactions with friends or by listening to people on the radio or on T
    7·1 answer
  • A package that includes hardware, software, and support from a single vendor is called a(n ____ package.
    6·1 answer
  • Point out the correct statement.
    11·1 answer
  • Identify traits of entrepreneurs. Check all of the boxes that apply.
    11·1 answer
  • 1. Write an if statement that assigns 20 to the variable y, and assigns 40 to the variable z
    10·1 answer
  • Atheel tests a program and gets a NameError. How can this be fixed?
    13·2 answers
  • Please help me answering this question
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!