Discover a world of knowledge and community-driven answers at IDNLearn.com today. Whether it's a simple query or a complex problem, our community has the answers you need.
Sagot :
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:
https://brainly.com/question/17378192
We appreciate every question and answer you provide. Keep engaging and finding the best solutions. This community is the perfect place to learn and grow together. Find clear and concise answers at IDNLearn.com. Thanks for stopping by, and come back for more dependable solutions.