You're not passing p and q from main into your add() function. Instead, inside the function, you're creating new local variables p and q, which you never initialise or assign values to.
You're also passing a mysterious variable a into the function. You never assign a value to this variable in main, and you don't use it ad all in add().
#include <iostream>
usingnamespace std;
int add(int, int);
int main()
{
int p = 0;
int q = 0;
int total_in_main = 0;
cout << "Enter a number : " << endl;
cin >> p;
cout << "Enter a 2nd number : " << endl;
cin >> q;
total_in_main = add(p, q);
cout << "Total is: " << total_in_main << endl;
}
int add (int x, int y)
{
int total = x + y;
return total;
}
Enter a number :
5
Enter a 2nd number :
8
Total is: 13
Program ended with exit code: 0
Send the two numbers p and q to the add function - via the bracketed numbers - they replace x and y. The add function does the addition and sends back its total which is stored as total_in_main when returned. Printing follows.