[Solved] error : too few arguments to function? [closed]


I did the exact same thing in another part of code and got no error or
any problem with it’s way of working but in this part and so it gives
me an error.

C does not guarantee to diagnose all incorrect code, neither at compile time nor at run time. Nevertheless, you should turn up your compiler’s warning level. If afterward it anywhere accepts a call to your triangle() function with other than exactly two arguments and without emitting at least a warning of some kind, then throw it out and choose a better one.

So the function is;

void triangle(int height,int base)
{
   printf("Enter the base of the triangle:");
   scanf("%d",&base);
   printf("\nEnter the height of the triangle:");
   scanf("%d",&height);
   int area;
   area = (height*base)/2;
   printf("\nTriangles area is %d.",area);
}

Note that your function does not actually use the value provided by the caller for either argument, nor does it in any way return any information to its caller, even if you call it with the correct number of arguments. If that’s what you want then it would be better to declare it to accept no arguments, and to call it that way:

void triangle(void) {
    int length;
    int height;
    // ...

Note that length and height are now strictly local variables. You call that variation like so:

triangle();

0

solved error : too few arguments to function? [closed]