Hello,
I was given a task to construct a program that should look like this:
"fun1" (function one) of type void must complete the given task and print out the end results whereas "fun2" provides the side results that are used by "fun1".Code:<...> <description of fun1> <description of fun2> main(){ <giving the program the initial parameters>; <fun1(<parameters>); }
I'm struggling to understand how those two functions should interact with each other, especially because the fun1 that requires the results of the fun2 is described before fun2. Also, with a given task, fun2 must send a whole lot of results that fun1 must check and print out whether they meet the conditions. What should be written in order to achieve that?In addition, I would be very grateful if you could tell me how the repeating answers could be eliminated.
So far I only have this:
The task is to construct a program where a user enters the area of a rectangle and the program prints out all the possible lengths and widths so their product is equal to the given area.Code:#include <stdio.h> void fun1 (int, int) { if (the "result of fun2"==S) {printf("%d %d", i, k);} /*The problem is, I don't know how "i" and "k" should be transfered to this function*/ } int fun2 (int) { int i, k; for(i=1; i<=S; i++) { for(k=1; k<=S; k++) { return i*k } } } main () { int S; printf("Enter the area of the rectangle.\n"); scanf("%d\n", &S); fun1(S); }
If you have any questions, I'll do my best.
Also, sorry if anything's hard to understand. English isn't my mother tongue.
Have a nice day!