Start New Discussion within our Software Development Community
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;
    return 0;

int addem(int a, int b){
    int c;
    return c;

Thank you

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

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)

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

This question has already been answered. Start a new discussion instead.