두 함수를 쓰려고하는데, 하나는 입력을 받아 다른 하나는 가속을 계산합니다. 컴파일러는 내 변수가 초기화되지 않았지만 입력 값을 가져야한다고 말합니다. 내가 도대체 뭘 잘못하고있는 겁니까.초기화되지 않은 변수
#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 클래스의 어느 부분에 있습니까? 참조에 의한 포인터와 전달이 무엇인지 아십니까? –
나는 우둔하다. 우리는 패스와 포인터에 대해 아직 알지 못했습니다. –