Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

Write a C program containing a function that takes has 2 integer parameters x and y and returns the value of x2 + y2. The main program should then allow the input of two integer values a and b and display the value of a2+b2. Please someone help me. Thank you so much.

OpenStudy (anonymous):

Its : x^2 + y^2 a^2+b^2

OpenStudy (e.mccormick):

What part of the code did you have trouble with?

OpenStudy (anonymous):

void quadratic(int x, int y); main() { int a, b, result; printf("Pls enter an integer value for a:"); scanf("%d", &a); printf("pls enter an integer value for b:"); scanf("%d", &b); result=quadratic(a,b); return result; } void quadratic(int x, int y) { int z; z = a^2 + b^2; return z; } I am not sure if its good. Can you please correct my code?

OpenStudy (e.mccormick):

``` #include <iostream> void quadratic(int x, int y); int main() { int a, b, result; printf("Pls enter an integer value for a:"); scanf("%d", &a); printf("pls enter an integer value for b:"); scanf("%d", &b); result = quadratic(a,b); return result; // HUH? Return on a main? } void quadratic(int x, int y) { int z; z = a^2 + b^2; // HUH? Where are a and b declaired? return z; } ```

OpenStudy (e.mccormick):

Oh, and you can put ``` above and below a code block to make it format properly.

OpenStudy (anonymous):

void quadratic(int x, int y); main() { int a, b, result; printf("Pls enter an integer value for a:"); scanf("%d", &a); printf("pls enter an integer value for b:"); scanf("%d", &b); result=quadratic(a,b); return result; } void quadratic(int x, int y) { int z; z = x^2 + y^2; return z; } Now is the code good?

OpenStudy (e.mccormick):

Did you try running it?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!