Question 1: Write a program, that during the entering of real resistance values prints the average resistance value.
Use a function Average_resistance() , to compute the average resistance.
make a PSD before writting the program.
1
Expert's answer
2012-04-03T11:17:48-0400
#include <iostream>
using namespace std;
double Average_resistance(){
int n = 0;
double sum = 0;
double val;
cout<<"Input real resistance values. Input -1 if you want to stop. ";
cin>>val;
while(val != -1){
n++;
sum += val;
cout<<"Current AV: "<< sum/n << endl;
cin>>val;
}
return sum/n;
}
int main(){
char input;
while(1){
cout<<"1 - count average resistance ";
cout<<"2 - exit ";
cin>>input;
if(input == '1'){
cout<<"---- Average value: "<<Average_resistance()<<" ----"<<endl;
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment