Here is the question: Write a program containing a function that takes has 2 integer parameters x and y and
returns the value of x^2 + y^2.
My codes:
#include<stdio.h>
#include<stdlib.h>
int Myfun(int x,int y);
int main()
{
int n,p,k,sum=0;
printf("Enter 1st integer: ");
scanf("%d", &n);
printf("Enter 2nd integer: ");
scanf("%d", &p);
sum=Myfun(n,p);
printf("%d\n", sum);
system("pause");
return (1);
}
int Myfun(int x, int y)
{
int n,p,sum=0;
sum = sum+(n*n)+(p*p);
return (sum);
}
ny problem is when i enter the two integers suppose 2 and 2 it should have given the output of 8 but instead it gives a different output. Need help about what is wrong with my codes?