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.Draw a PSD for the program program before writing the program.
// Averageresistance.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include
<conio.h>
#include <iostream>
using namespace std;
double Average_resistance(double arr[],int n){
double sum=0;
for(int
i=0;i<n;i++){
sum+=arr[i];
}
double
average;
average=sum/n;
return average;
}
int _tmain(int argc,
_TCHAR* argv[])
{
int n;
double
arrayionumber[1000];
cout<<"Enter the number of element:
";
cin>>n;
for(int i=0;i<n;i++){
cout<<"Enter the
element #"<<(i+1)<<"=
";
cin>>arrayionumber[i];
}
cout<<"The average resistance
is: "<<Average_resistance(arrayionumber,n);
getch();
return
0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++