Wrong in the cout(functions)

I can't find the wrong in this code i think i have a small problem at the cout but i don't know how to solve my problem . Can anyone help me and tell me why this is wrong ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int sum (int a,int b);

int main(){
int c,d;
cin>>c;
    cin>>d;
cout<<sum(c+d)<<endl;
}
int sum(int a,int b){
int result;
result=a+b;
return result;
}
Your function takes 2 integers, you're only giving it one.

cout<<sum(c+d)<<endl;

change it to -

cout<<sum(c,d)<<endl;
Last edited on
thank you very much tarikNeaj and DrZoudberg
Topic archived. No new replies allowed.