Thread: too few arguments to function

  1. #1
    Registered User
    Join Date
    Feb 2014
    Location
    Manassas, Virginia, United States
    Posts
    2

    too few arguments to function

    Hi, can someone help me with this. I keep getting the too few arguments to function and I'm not sure why. Im new into programming.
    Code:
    #include<stdio.h>
    #include<math.h>
    float total_s_area(float b, float p)
    {
          return (b + (1.0/2)* p);
    }
    float volume(float b, float h)
    {
          return ((1.0/3) * b * h); 
    }
    int main()
    {
        float w, h;
        float parameter, result;
        
        printf("Enter the width of the pyramid: ");
        scanf("%f", &w);
        printf("Enter the height of the pyramid: ");
        scanf("%f", &h);
        
        printf("Enter the parameter of the pyramid: ");
        scanf("%f", &parameter);
        // total area
        result = total_s_area(parameter/6); //function call
        printf("The total area of pyramid = %.6f\n", result);
        
        //volume
        result = volume(parameter/6);
        printf("The volume of the pyramid = %.6f\n", result);
        system ("PAUSE");
        
        return 0;
    }
    yes I read the post about tags but I'm new so please bear with me

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You declared total_s_area as taking two arguments, but called it passing only one argument. The same applies for volume.
    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

  3. #3
    Registered User
    Join Date
    Feb 2014
    Location
    Manassas, Virginia, United States
    Posts
    2
    I see that, thanks I will try to change that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2012, 02:37 PM
  2. too few arguments to function 'pow'
    By MRidiot in forum C Programming
    Replies: 4
    Last Post: 12-27-2011, 12:12 PM
  3. function with variable function arguments
    By Kyl in forum C Programming
    Replies: 10
    Last Post: 12-21-2011, 02:56 PM
  4. Function arguments
    By cpudaman in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2007, 09:57 PM
  5. Replies: 9
    Last Post: 01-02-2007, 04:22 PM

Tags for this Thread