i need to get an algorithm ( flowchart and pseudocode)
computer programing (C++)
i need to get an
#include<iostream> //header file
using namespace std;
float function1(float, float[]); //function prototype for function1
float function2(float, float[]); //function prototype for function2
float function3(float[], float[]); //function prototype for function3
int function4( );
int main( ) //main function
{
float vin, R[4], i[4], v[4]; //declare float variables which are R,i and v
int choice; //declare int variables for choice
cout<<"Enter vin: \n"; //ask user for enter vin
cin>>vin; //read the input
cout<<"Enter R1, R2, R3: \n"; //ask the user enter value R1,R2, and R3
cin>>R[1]>>R[2]>>R[3]; //read input
cout<<"Select from the menu: \n"; //ask user to select the menu
cout<<"1. Calculate i1.\n2. Calculate v2 and i2. \n3.Calculate v3 \n4. Exit \n"; //ask user for select menu
cout<<"Enter a choice: "; //ask user to enter the choice
cin>>choice; //read the choice
i[1]=function1(vin, R); //function call of the function 1()
i[2]=function2(vin, R); //function call of the function 2()
v[3]=function3(i, R); //function call of the function 3()
switch (choice) //switch statement choice
{
case 1 : cout<<"\ni1 ="<<i[1]; //display value i1
break; //system break
case 2 : cout<<"\nv2 ="<<vin<< "\ni2 = "<<i[2]; //display value v2 and i2
break; //system break
case 3 : cout<<"\nv3 ="<<v[3]; //display value v3
break; //system break
case 4 : function4(); //function call of the function4()
break; //system break
default: cout<<"Incorrect input!"; //display incorrect input if default
}
return 0;
}
float function1(float vin, float R[]) //function definition for function1
{
float i1 = vin/(R[2]*(R[1]+R[3])/R[1]+R[2]+R[3]); //calculate value i2 by using this formula
return i1;
}
float function2(float vin,float R[]) //function definition for function2
{
float i2 = vin/(R[1]+R[3]); //calculate the value of i2 by using this formula
return i2;
}
float function3(float i[],float R[]) //function definition for function3
{
float v3 = i [2]*R[3]; //calculate the value of v3 by using this formula
return v3;
}
int function4( ) //function definition for function4
{
cout<<"Exit the Program!"; //ask user to exit the program
exit(0);
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)