integers

how do i implement "int getSum(int A, int B, int C) into this code"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <cmath>
using namespace std;

//int getSum(int A, int B, int C)
int main(){
  // Write your code here
    int a=1;
    int b=2;
    int c=3;
    
    cout<< a+b+c;
  return 0;
}

Chapter 2 at Learn C++ is basic information about functions (and files):

https://www.learncpp.com/cpp-tutorial/introduction-to-functions/
on my cout line do I have to use getSum? if so what am I doing wrong?
or can I just use A+B+C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <cmath>
using namespace std;

int getSum(int A, int B, int C) {
    return A+B+C;
}
int main (){
    int A= 1;
    int B= 2;
    int C= 3;
    
    cout<< getSum;
  return 0;
}
cout<< getSum

The idea is that you send some values to the function getSum(), not just name it.

Try
cout<< getSum(A,B,C)
or even
cout<< getSum(1,2,3)
ahh I see now thank you
what am I doing wrong?

Chapter 2 covers that:

https://www.learncpp.com/cpp-tutorial/introduction-to-function-parameters-and-arguments/

Think "parameters"...
@Furry Guy
thanks I see it in the examples now
Topic archived. No new replies allowed.