Help with C++
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.
#include#include 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 Replies
[Prototype]I didn't checked it for error but that's very ugly code for sure. No proper indentation, meaningless variable names, "{a=" -> Who even taught you to do this? 😲
You should rather re-write it with proper coding etiquette. That will help for you and others to identify what you're trying to do and what is going wrong. PuneetVermaNo No. This has been written correctly. The problem is it might look weird to you because it is design of structures of civil and mechanical in C++ harmanveer kaur#include
#include
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)// modified
{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{
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 = "<cout<<"Width of the channel = "< cout<<"Discharge of channel = "< return 0; //modified
}
float vel (float r,float bs)
{
float n=0.018,vc;
vc=(1/n)*sqrt(bs)*pow(r,2.0/3.0);
return vc;
} PuneetVerma#include
#include
using namespace std;
float vel(float,float,float);
int main()
{
float p,qc,qr,d,w,ac,h,hg,v,b=1.5,dl=8,ss1=1.0,ss2,bs,wpr;
int x,y,z;
cout<<"For Lined Channe.. Press 1\nFor Unlined Channel.. Press 2\n"<cin>>x;
cout<<"For Cutting Section.. Press 3\nFor Filling Section.. Press 4\n"<cin>>y;
cout<<"For Power channel.. Press 5 \nFor Head Race Channel.. Press 6"<cin>>z;
if(x==1&&y==3)
{ss2=1;
}
else if(x==1&&y==4)
{ss2=1.5;
}
else if(x==2&&x==3)
{ss2=1.5;
}
else
{
ss2=2;}
if(z==5)
{bs=1.0/200.0;
}
else
{bs=1.0/500.0;
}
cout<<"Enter Power Potential in MW = ";
cin>>p;
cout <<"Enter Gross Head in meters = ";
cin>>hg;
h=(0.9*hg);
qr=(p*1000)/(9.81*0.8*h);
qc=0.0;
d=0.0;
while(qc{d=d+0.05;
w=d;
if(d<=4.0)
{ac=w*d;
wpr=w+(2*d);}
else if(d<=8.0)
{ac=(w+ss1*d)*d;
wpr=w+(2*pow(1.0+pow(ss1,2.0),0.5)*d);}
else
{ac=((w+ss1*dl)*dl)+((w+2*ss1*dl+2*b)+ss2*(d-dl))*(d-dl);
wpr=w+(2*pow(1.0+pow(ss1,2.0),0.5)*dl)+(2*b)+(d-dl)*pow(1+pow(ss2,2.0),0.5);
}
v= vel(ac,bs,wpr);
qc=ac*v; }
if(d<=4.0)
{cout<<"Channel Section is Rectangular\n";}
else if(d<=8.0)
{cout<<"Channel Section is trapezoidal\n";}
else
{cout<<"Channel is composite\n";}
cout<<"Value of Diameter in metre = "<cout<<"Value of Width in metre = "< cout<<"Value of Discharge = "< }
float vel(float a,float bs,float pe)
{
float n,r,v;
n=0.018;
r=a/pe;
v=(pow(r,2.0/3.0)*pow(bs,1.0/2.0))/n;
return v;
}
I tried to do some changes and it is working now. Don't find exact difference. simplycoderLook at the code snippet below.
if (z=4) will always be true as assignment operator is used.if (z=4)
{cout<<"Power Channel\n";
bs=(1/200);
}
I have not run your code through compiler, but this was surely one of the mistakes in your code, there may be more. Dennis Ighowhoplease what is this program suppose to do? i mean the output?You are reading an archived discussion.
Related Posts
The amount of visual data is growing and it is growing fast. How fast? See for yourself:
Facebook users upload 350 million new photos each day (Business Insider)
Snapchat sees...
Quote:
The phenomenon of 3-D printing is allowing medical device makers to do amazing things, as showcased by the recent FDA approval of the first 3-D printed facial implant. But...
WhatsApp has been showing the nasty "Failed. Out of memory. Please try again later." error message whenever I send multiple photos to a group or any of my content. After...
Story of a roadside corn roaster and his passion towards technology.
^ Shot by Subhash G.
I am Priya Tanwar pursuing my graduation in IT.
Programming skill: Android,Java, C#, vb.net, Haskell, C++, C.
Other skill: web development,Photoshop,sketching portraits.
Location: India.
Work Experience: worked as an intern...