Function Output Help

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

int sum(int a,int b){
          int c=0;
          c=a+b;
          cout << c;
          }
            
main()
{
      int x=1;
      int y=3;
      
      cin >> x;
      cin >> y;
      sum(x,y);
      system("pause");
           
}


I wrote this file when i run it nothing showing no cin no sum etc just blank black screen...
1
2
cin >> x;
cin >> y;

This will wait for the user two enter 2 integer values. If you do that, and press enter, do you get something?
Once I ripped out that system("pause") and replaced main() with int main() (to make it C++ code) I got the following output:

6
7
13


The 6 and 7 was what I typed in. Works fine.
Topic archived. No new replies allowed.