0

I wrote the code for the task, but it is not executed as it should be, add or suggest what should be written so that it work

Here is the condition of the problem 10 Calculate the product of the minimum and maximum values ​​of the function. Number of argument values ​​n=19. The y argument changes from an initial value of 0.1 in steps of 0.75 (radians): g = 1+c/(b-y)sin³(y) c = 3452 b = 1673 #include <stdio.h> #include <math.h> [[double funcg(double,double, double);]] int main() { int i, n, nmax; double b,c,y,ystep; double xmin, xmax; double g; double x; n=1; nmax=19; b=1.673; c=3.452; y=0.1; ystep=0.75; xmin=xmax=funcg(b,c,y); printf("Результат\n"); for (i = n; i <= nmax; i++) { y=y+ystep; g=funcg(b,c,y); if (xmin>g) xmin=g; if (xmax<g) xmax=g; printf("Аргумент %4.3f, Min %4.3f, Max %4.3f \n", y, xmin, xmax); } x=xmin*xmax; printf("xMin= %4.3f, xMax= %4.3f \n", xmin, xmax); printf("Результат = %4.3f \n", x); return 0; } [[double funcg(double b, double c, double y) ]] { [[double g;]] g=(1+c/((b-y)*pow(sin(y),3))); return g; }

12th Dec 2022, 10:19 AM
Marjan Borodaki
7 ответов
+ 2
How it should work? What is your expected output?
12th Dec 2022, 10:40 AM
Jayakrishna 🇮🇳
+ 2
what is the correct cycle according to you? y value is different in each cycle. Other values depends on your calculations. g value is also different. You are taking b=1.673 , c = 3.452 but description says to use b=1673, c = 3452. which one is correct??!!
12th Dec 2022, 11:44 AM
Jayakrishna 🇮🇳
+ 2
Sry still not clear to me.. Marjan Borodaki What is a certain point it strucking according to you..? And upto where you want to continue..? Your loop runs from i=n to nmax times.. In each iteration, it calling funcg() and getting results... So it can be, only determined correct solution if you know the correct output...! Hope you understand ...
12th Dec 2022, 6:18 PM
Jayakrishna 🇮🇳
+ 1
Are you need to deal with integers?
12th Dec 2022, 11:51 AM
Jayakrishna 🇮🇳
0
How to add code without (double) so it does the same thing. I've enclosed them with double square brackets [[ ]]
12th Dec 2022, 10:19 AM
Marjan Borodaki
0
The cycle is not correctly executed, here a few times the same number falls out, but there should be the correct cycle.
12th Dec 2022, 11:32 AM
Marjan Borodaki
0
the form is not important here, the main thing is that the cycle is performed correctly, that is, find the maximum and minimum value of the cycle, and their product. The problem is that the cycle gets stuck until a certain number and does not continue. what can this line be replaced with, because it does not work correctly [[funcg(double,double, double);]].
12th Dec 2022, 3:21 PM
Marjan Borodaki