How can I write a function that receives two pointers of type INT as arguments? The function reads two integers from the user and stores them in its arguments. It then calculates the sum of the integers and returns the result.
Below is the code that I wrote. It was really crappy and contains a lot of error.
'''
#include<stdio.h>
//function prototype
int sum(int* first, int* second);
//function definition
int sum(int* first, int* second)
{
int sum2;
*first = &p;
*second = &q;
sum2 = first + second;
printf("sum of the 2 numbers is %d", sum2);
return;
}
void main()
{
int p;
int q;
printf("enter the two numbers two add");
scanf("%d %d", &p, &q);
sum(&p, &q);
}
'''