0
Please tell me where it goes wrong as the following C++ code gives
the error message: 
**addem.cpp:5: error: too few arguments to function int  addem(int, int)**


`#include <iostream>
using namespace std;

int addem(int, int);

int main()
{
    int x=5;
    int y=2;
    int z;
    z = addem(x+y);
    cout << "The value of z: "<<z;
    system("PAUSE");
    return 0;
}

int addem(int a, int b){
    int c;
    c=a+b;
    return c;
}'


Thank you

Edited by dellat

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by dellat
Featured Replies
  • 1

    `x+y` evaluates to a single integral value. You probably intended to write that as: `z = addem(x, y);` Read More

  • 1

    When youy give `x + y` separately, the compiler will add the values of x and y. Here you have used a function to add he values. In this fuction, `addem(int , int)`, it can be called only as `z = addem(x ,y);` but not as `z = addem(x + … Read More

1

x+y evaluates to a single integral value. You probably intended to write that as: z = addem(x, y);

1

When youy give x + y separately, the compiler will add the values of x and y.

Here you have used a function to add he values. In this fuction, addem(int , int), it can be called only as z = addem(x ,y); but not as z = addem(x + y)

0

I have understood the mistake. Thank you very much for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.