Can you please rectify error in this program.
I am not getting output of last three cout statements.
I am not getting output of last three cout statements.
Code:
#include <iostream>
#include <cmath>
using namespace std;
float vel (float, float);
int main ()
{
float p,hg,h,d,w,qc,qr,bs,ac,wpr,s,r,v,ss1,ss2,dl=8.0,b=1.5;
cout<<"Enter Power Potential in MW = ";
cin>>p;
cout <<"Enter Gross Head in meters = ";
cin>>hg;
float x,y,z;
cout<<"\nFor Lined Channel ..press 0\nFor Unlined Channel ..press 1\n";
cin>>x;
cout<<"\nFor Channel in Cutting ..press 2\nFor Channel in Filling ..press 3\n";
cin>>y;
cout<<"\nFor Power Channel ..press 4\nFor Head Race Channel ..press 5\n";
cin>>z;
if (x==0 && y==0)
{
cout<<"Channel is Lined and Section is in Cutting\n";
ss1=1, ss2=1;
}
else if (x==0 && y==1)
{
cout<<"Channel is Lined and Section is in Filling\n";
ss1=1, ss2=1.5;
}
else if (x==1 && y==0)
{
cout<<"Channel is Unlined and Section is in Cutting\n";
ss1=1, ss2=1.5;
}
else
{
cout<<"Channel is Unlined and Section is in Filling\n";
ss1=1, ss2=2;
}
if (z=4)
{
cout<<"Power Channel\n";
bs=(1/200);
}
else
{
cout<<"Head Race Channel";
bs=(1/400);
}
h=0.9*hg;
qr=(p*1000)/(9.81*0.80*h);
qc=0.0;
d=0.0;
while(qc<qr)
{
d=d+0.005;
if (d<=4.0)
{
w=d;
ac=w*d;
wpr=(w+(2*d));
}
else if (d<=8.0)
{
w=2*d;
ac=w*(w+ss1*d);
wpr= (w+ (2*d*sqrt(pow(ss1,2.0)+1)));
}
else
{
w=2*d;
ac=(w+ss1*dl)*dl+(w+2*ss1*dl+2*b+ss2*(d-dl)*(d-dl));
wpr=(w+(2*dl*sqrt(1+pow(ss1,2.0))+(2*b)+(2*(d-dl)*sqrt(1+pow(ss2,2.0)))));
}
r=ac/wpr;
v=vel(r,bs);
qc=ac*v;
}
cout<<"Depth of the channel = "<<d<<endl;
cout<<"Width of the channel = "<<w<<endl;
cout<<"Discharge of channel = "<<qc<<endl;
}
float vel (float r,float bs)
{
float n=0.018,vc;
vc=(1/n)*sqrt(bs)*pow(r,2.0/3.0);
return vc;
}