Problems compiling this program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muhammad rehan

    Problems compiling this program

    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<math.h>
    #include<iomanip.h>
    {
    	 double compute(double ws)
    	 double sqrt(double r)
    	 double main()
    	 {
    		double mf,v[2],a[2],q,h[2],sv[2],z[2],r,ans2,c,ws;
    		double g = 9.8;
    
    		cout<<"Device: Centrifugal compressor ";
    		cout<<"Mass flow rate mf (Kg/min) = ";
    		cin>>mf;
    
    
    			mf = mf/60;
    
    		cout<<"Conditions at inlet: ";
    		cout<<"v1 (m/s) = ";
    		cin>>v[0];
    		cout<<"h1 (KJ/Kg) = ";
    		cin>>h[0];
    		cout<<"Specific volume (cubic meter/Kg) = ";
    		cin>>sv[0];
    		cout<<"Height of inlet above the ground z1 = ";
    		cin>>z[0];
    		cout<<"Condition at exit: ";
    		cout<<"v2 (m/s) = ";
    		cin>>v[1];
    		cout<<"h2 (KJ/Kg) = ";
    		cout<<"Specific volume (cubic meter/Kg) = ";
    		cin>>sv[1];
    		cout<<"Height of outlet above the ground z2 = ";
    		cin>>z[1];
    		cout<<"Heat loss to cooling water q (KJ/min) = ";
    		cin>>q;
    		cout<<"From SFEE ";
    
    		  double compute()
    		 {
    		 ws = -1*(mf((h[1]-h[0])+1/2(v[1]*v[1]-v[0]*v[0]+g(z[1]-z[0]))+q);
    		 if (z[0]=z[1])
    		 {
    				g(z[1]-z[0]) = 0;
    		 }
    
    		 cout<<"Thus the power of motor required to drive the compressor is = "<<ws<<endl;
    		 return 0;
    		 }
    
    
    		 cout<<"Mass flow rate at inlet = Mass flow rate at outlet = "<<mf<<endl;
    
    				a[0] = mf*sv[0]/sv[0];
    				a[1] = mf*sv[1]/sv[1];
    				r = a[0]/a[1];
    
    
    
    		  cout<<"Thus the ratio of inlet pipe diameter to outlet pipe diameter is = "<<sqrt(double r)<<endl;
    
    
    
    
    
    		 getch();
    		 return 0;
    		 }
    
    
    		 }
    Last edited by Banfa; Oct 2 '10, 10:56 AM. Reason: Added [code]...[/code] tags round he code.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You will need to do more than just post your code you will need to describe the problems you're having as well as post the text of any compiler errors you are getting.

    However for starters
    • The braces at lines 5 and 73 are just wrong
    • main returns int not double
    • You can not define functions inside other functions as you have done at line 41
    • You shouldn't declare sqrt at line 7, it is declared in math.h which you have included.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      It is best if you can cut-and-paste your compiler errors into your post. These compiler error messages carry a lot of information.

      Comment

      Working...