私は入力を受け取る関数と加速を計算する関数の2つを記述しようとしています。コンパイラは私の変数が初期化されていないが、入力からの値を持つべきであると私に伝えています。私は間違って何をしています。初期化されていない変数
#include <stdio.h>
#include <stdlib.h>
void input_instructions(double vi, double vf);
double compute_acceleration(double vi, double vf);
int main()
{
double vi;
double vf;
double acc;
double t;
input_instructions(vi, vf);
acc = compute_acceleration(vi,vf);
t = (vf - vi)/acc;
printf("The constant acceleration of the cyclist is %.2f and it will take him %.2f minutes/seconds/"
"to come to rest with an initial velocity of 10mi/hr.\n", acc, t);
}
void input_instructions(double vi, double vf)
{
printf("This program will calculate the rate of accleration and the time it takes/"
"the cyclist to come to rest\n");
printf("Enter inital velocity=>");
scanf("%lf", &vi);
printf("Enter final velocity");
scanf("%lf", &vf);
}
double compute_acceleration(double vi, double vf)
{
double t = 1;
double a = (vf-vi)/t;
return (a);
}
これはCでの関数の動作ではありません。おそらくhttps://stackoverflow.com/documentation/c/1006/function-parametersを試してみてください。 –
あなたはちょっと気味が悪いようです。あなたはCクラスのどの部分にいるのですか?ポインタと参照渡しが何であるか知っていますか? –
私は無知です。私たちはまだ合格点と指針について学んでいない。 –