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

Write a C/C+ function called Parallel that accepts two input resistor values (in

ID: 3795568 • Letter: W

Question

Write a C/C+ function called Parallel that accepts two input resistor values (in Ohms) and then multiplies them and divides by their sum: Double Parallel (double R1, double R2) {Rpar = (R1*R2)/(R1 + R2);} Use return statement to send the calculated value of Rpar to the main program. Test your function in a program that calculates the equivalent resistance of a 250 and 500 ohm resistors in parallel, Write a C/C+ named Stir uses the Stirling formula to approximately calculate the value of the factorial of an input integer n: Use a return statement to return value of Fact to the main program. Float STIR(float n) {Float Fact = squareroot (2*pi*n)*(n/2.7)^n;}

Explanation / Answer

1) Please refer below code for reference

#include<iostream>

using namespace std;

double Parallel(double R1, double R2)
{
return (R1 * R2)/(R1 + R2);
}
int main()
{
double R1,R2,Rpar;

cout<<"Enter values of R1 and R2 ";
cin>>R1>>R2; //Accepting user values

Rpar = Parallel(R1,R2); //calling function

cout<<"Resultant of parallel combination is "<<Rpar<<endl;
return 0;
}

Please refer below execution of code

Enter values of R1 and R2 250 500
Resultant of parallel combination is 166.667

Process returned 0 (0x0) execution time : 8.141 s
Press any key to continue.

2) Please refer below code for reference

#include<iostream>
#include<cmath>

#define pi 3.14159 //using pi value upto 5 decimal places
using namespace std;

float STIR(float n)
{

return (sqrt(2 * pi * n) * pow((n/2.7),n)); //sqrt() and pow() are part of cmath file of lib
}
int main()
{
float n,fact;

cout<<"Enter Number for factorial "<<endl;
cin>>n;

fact = STIR(n);
cout<<"Factorial is "<<fact<<endl;
return 0;
}

Please refer below output for reference

Enter Number for factorial
5.2
Factorial is 172.67

Process returned 0 (0x0) execution time : 14.774 s
Press any key to continue.

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