c - Force, Square Root and Table Program -


i'm trying put program compute results in form of table. have hydraulic lift can shown small force (i'm calling f1) acting on piston of diameter (d1) can multiplied large force (f2) acting on piston of diameter (d2), , lift operating @ 90% efficiency. finally, d2/d1 being represented dr.

now, i'm trying use formula wrote "dr = sqrt(f2 / 0.9(f1))" give results based on me plugging in random numbers f1 , f2 , put them table split sections "input f (measured in lbs.)", "output f (lbs.)", , "dr (d2/d1)". however, before got dealing table, started having trouble compiling errors first part.

this have now.

#include <math.h> #include <stdio.h> #include <stdlib.h>  int main() {     int dr;     int f1, f2;     int d1, d2;     int lbs;     int integer;     double square_root;      if(integer<0)         {         printf("cannot find square root of negative number.");         scanf("%d", &integer);         return 0;         }         else         {         square_root = sqrt (integer);         printf("\nthe square root of large force (f2) divided 90% of small force (f1)");          }          f1 = 50;         f2 = 4000;         dr = sqrt(f2 / 0.9(f1));          return 0; } 

this:

dr = sqrt(f2 / 0.9(f1)); 

writes expression if (almost) math. in c, must use * operator multiply things, cannot suppress in math.

it should be:

dr = sqrt(f2 / (0.9 * f1)); 

note since dr int, result truncated integer.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -