Design four separate programs in C++ using prototype functions which will comput
ID: 1810347 • Letter: D
Question
Design four separate programs in C++ using prototype functions which will compute the equivalent resistance to anarbitrarynumber of resistors connected inseriesif the user types a value of 0 on the keyboard for a runmode operator, and the equivalent resistance to anarbitrarynumber of resistors connected inparallelif the user types a value 1 for the runmode operator. Your programs must meet the following requirements:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
i)The selection as to whether the resistors are connected in series or in parallel is to be implemented using the SWITCH command.
ii)The implementation of the phrase
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
int d;
int r;
float r_equiv;
int rval;
int rnext=0;
float r_prev;
count<<"If resistor are in parallel enter 1 and if in series enter 0.";
cin>>d;
if(d==0)
{
int r[10],
num,i,Rs=0;
clrscr();
count<<"Enter the number of Resistances : ";
cin>>num;
count<<"nEnter Value of Each Resistance : n";
for(i=0;i<num;i++)
{
count<<"nR%d : ",i+1;
cin>>r[i];
}
for(i=0;i<num;i++)
{
Rs = Rs + r[i];
}
count<<"/nEquivalent Series Resistance : ,Rs;
return 0;
}
else
{
cout<<"This program will calculate the equivalent resistance of any number of parallel resistors.";
cout<<" Enter the number of resistors in the parallel circuit:";
cin>>r;
for(int n=1;n<=r;n++)
{
cout<<" Enter the value of resistor #"<<n<<":";
cin>>rval;
rnext=rval;
if(n==1&&n==2){r_prev=int(rval*rnext/rva
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.