Thread: prototype function sqrt velocity(v)

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    15

    prototype function sqrt velocity(v)

    Code:
    question I am trying to computed the time it takes for a projectile to hit the ground. 
     the problem is that i need to square the imput of velocity before i do the calculation. the question I have is that if it's possible to have multiple arguments inside the brakets after main and if it is can someone help me.
    
    #include <stdio.h>
    #include <math.h>
    double distance (double a, double v, double g);
    int square(int y);
    double height(double v, double a, double g);
    double time (double v, double a, double g);
    double sqrt(double num);
    int main(void)
    {
            double d, h, datha, v, t;
            int velocity, degrees;
            const double pi=3.14159265359; // the value of pi
            const double g= 9.81; // acceleration due to gravity m/s^2
            printf(" enter the angle in degrees");
            scanf("%d", &degrees);
            datha = degrees * pi/180;
            printf("Enter the initial veloity\n");
          
      printf("Enter the initial veloity\n");
            scanf("%lf", &v);
            velocity = square(v);
            d = distance(datha, velocity,g);
            printf("the reange of the projectile was %.2f\n: ", d);
            h = height(datha, velocity, g);
            printf("the maximum height achieveid was:%.2lf: ", h);
            t = time(datha, velocity, g);
            printf(" the time was %.2f", t);
            return 0;
    }
    int square(int y){
            return pow(y,2);
    }
    double distance(double a, double v, double g ){
                          return v *sin(2*a)/g;
    }
    double height(double v, double a, double g){
            return v*sin(a)/g;
    }
    double time(double v, double a, double g){
            return sqrt v;
            return 2*v*sin(a)/g;
    }

  2. #2
    Registered User
    Join Date
    Mar 2013
    Posts
    15
    this is the error I am getting

    âtimeâ:
    q1.c:51: error: incompatible types when returning type âdouble (*)(double)â but âdoubleâ was expected
    q1.c:51: error: expected â;â before âvâ

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    sqrt is the name of a function in the standard library, available via <math.h>. Use a different name. The same goes for time, though since you did not include <time.h> that name collision probably just has not surfaced yet.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sqrt function
    By kbpsu in forum C++ Programming
    Replies: 16
    Last Post: 04-02-2009, 11:32 PM
  2. Having trouble with the sqrt() function.
    By SlyMaelstrom in forum C++ Programming
    Replies: 5
    Last Post: 11-02-2005, 01:08 PM
  3. sqrt() function help
    By willc0de4food in forum C Programming
    Replies: 5
    Last Post: 03-14-2005, 09:07 PM
  4. Sqrt() Function
    By tmoney$ in forum C Programming
    Replies: 4
    Last Post: 04-22-2003, 04:31 PM
  5. sqrt function
    By Extol in forum C++ Programming
    Replies: 2
    Last Post: 04-04-2003, 06:04 AM