#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
double V,I,pf,Ib;
unsigned short int choice;
int In = 0;

cout<<"Please choose power supply type\n";
cin>>choice;

switch(choice)
{
case 1:cout<<"You have chosen a single phase power supply\n";
	break;
case 2:cout<<"You have chosen a three phase power supply\n";
		   break;
default:cout<<"Invalid Choice Try Again\n";
	break;

}
cout<<"Please enter the value for I\n";
cin>>I;
cout<<"Please enter the value for V\n";
cin>>V;
cout<<"Please enter the value for pf\n";
cin>>pf;

if(choice<2)
{
	cout << "Ib in single phase is " << setprecision(4)
     << (V*I)/V/pf
     << setprecision(4) << endl;
}
else
{
	cout << "Ib in three phase is" << setprecision(4)
     << (V*I)/(1.732*V*pf)
     << setprecision(4) << endl;
}

while(Ib>In)
{
	In+=1;
	
}

return 0;
}

Hi im new to C++ and was wondering if i could get some help how do i take the value accquired in the if else and assign it to the variable Ib?

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
double V,I,pf,Ib;
unsigned short int choice;
int In = 0;

cout<<"Please choose power supply type\n";
cin>>choice;

switch(choice)
{
case 1:cout<<"You have chosen a single phase power supply\n";
	break;
case 2:cout<<"You have chosen a three phase power supply\n";
		   break;
default:cout<<"Invalid Choice Try Again\n";
	break;

}
cout<<"Please enter the value for I\n";
cin>>I;
cout<<"Please enter the value for V\n";
cin>>V;
cout<<"Please enter the value for pf\n";
cin>>pf;

if(choice<2)
{
     Ib=(V*I)/V/pf;//First compute Ib here
	cout << "Ib in single phase is " << setprecision(4)
     << Ib//Then output the value
     << setprecision(4) << endl;
}
else
{
    Ib=(V*I)/(1.732*V*pf);//Compute first
	cout << "Ib in three phase is" << setprecision(4)
     << Ib<<endl//then output
     << setprecision(4) << endl;
}

while(Ib>In)
{
	In+=1;
	
}

return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.