Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Also Draw a Flowchart of it. Preliminary C++ Program Tasks: Repeat Laboratory Ex

ID: 3776793 • Letter: A

Question

Also Draw a Flowchart of it.

Preliminary C++ Program Tasks: Repeat Laboratory Exercise 6 with these modifications: Write a C++ program to calculate the resistance of resistors connected either in series or parallel using array. Assume that the program can handle up to 1000 resistors. The print output format of the resistance must satisfy this additional requirement: Print the total resistance followed by values of each resistor. Example: Display For series configuration: Total series resistance is 2.123 K Ohm for 3 resistors: 1000 Ohm, 1000 Ohm, 123 Ohm. Display For parallel configuration: Total parallel resistance is 500 Ohm for 2 resistors: 1000 Ohm, 1000 Ohm. Show Instructor or Lab Assistant: Show well-documented and correct C++ program, and run output to verity that your program work as intended.

Explanation / Answer

#include <iostream>
using namespace std;

// function to find resultant series values
float series(float r[],int n){
float sum=0;
for(int i=0;i<n;i++)
sum += r[i];
return sum;
}

// function to find resultant parallel values
float parallel(float r[],int n){
float sum=0;
for(int i=0;i<n;i++)
sum = sum +( 1/ r[i]);
return 1/sum;
}

//main function
int main() {
int n;
   cout<<"Enter number of resistance";
   cin>>n;
   float res[n];
   cout<<"Enter each resistance values in ohms";
   for(int i=0;i<n;i++)
   cin>>res[i];
   cout<<" Total series resistance is "<<series(res,n)<<" for "<<n<<" resistors: ";
   for(int i=0;i<n;i++)
   cout<<res[i]<<" Ohm, ";
   cout<<" Total series resistance is "<<parallel(res,n)<<" for "<<n<<" resistors: ";
   for(int i=0;i<n;i++)
   cout<<res[i]<<" Ohm, ";
   return 0;
}

===================
output

===================

Enter number of resistance 2

Enter each resistance values in ohms 1000 1000

Total series resistance is 2000 for 2 resistors:
1000 Ohm, 1000 Ohm,
Total series resistance is 500 for 2 resistors:
1000 Ohm, 1000 Ohm,

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote