Skip Navigation
C & C++ @lemmy.ml the_tech_beast @lemmy.ml

What is the use of a void function if it doesn't return a value?

7
7 comments
  • #include <iostream>
    using namespace std;
    void sum()
    {
        int a, b, s;
        cin >> a >> b;
        s = a + b;
        cout << s;
    }
    int main()
    {
        sum();
    }
    

    Also why does this function return a value?

    for example, a = 45 and b = 45

    I get the sum as 90

7 comments