私はこのプログラミング全体に慣れていないので、我慢してください。二次軸と x 軸の間の面積を計算できるプログラムを作成したいと考えています。現在、私のコードは、a が正で c が負の関数用にのみ設計されています。
#include <stdio.h>
int main()
{
float a;
float b;
float c;
float x; /* this is the zero that is to the right*/
float y; /* this is the zero that is to the left*/
float z;
{
printf("Consider the function ax^2 + bx + c\n");
printf("Enter the a value: \n");
scanf("%f",&a);
printf("Enter the b value: \n");
scanf("%f",&b);
printf("Enter the c value: \n");
scanf("%f", &c);
x = (( -b + sqrt(b*b - 4*a*c)) / (2*a));
y = (( -b - sqrt(b*b - 4*a*c)) / (2*a));
do {
z=(((y+0.01)-(y))*((a*(y*y))+(b*y)+(c)));
y+0.01;} while (x>y);
if (y>=x) {
printf("The area is %f", z);
}
問題は、プログラムの実行が停止しないことです。私がやろうとしているのは、小さな正方形を作り、その面積を測定することです (LRAM と RRAM を思い出してください)。つまり、(ゼロ + 少し) y の値 (a*(y*y))+(b*y)+(c))) を掛けたものです。
任意のヒント?