I need to get an Algorithm (pseudocode and flowchart) note: give a computerized answer. #include //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 ="<
computer programing C++
I need to get an
note: give a computerized answer.
#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);
}
Step by step
Solved in 4 steps with 2 images