程序没有显示错误,但无法编译。您能帮我解决这个问题吗?
int main(void) {
printf("\n*************************************************************\n");
printf("\n*************************************************************\n");
printf("\n******** Program find the solution to which car you *********\n");
printf("\n******* could still earn if you received A's for the ********\n");
printf("\n********* remainder of your undergraduate classes. **********\n");
printf("\n*************************************************************\n");
printf("\n*************************************************************\n");
printf("\n You will be asked to enter your current GPA with at most 3 \n");
printf("\n Decimal places and the number of credit hours that the GPA \n");
printf("\n Was based on, which should be a positive number. \n");
printf("\n And the honors you qualify for will be displayed to screen.\n");
printf("\n*************************************************************\n");
printf("\n*************************************************************\n");
printf("\nPlease enter your current GPA with at most 3 decimal places.\n");
printf("\nFor example, for a GPA of 2.3333333333, enter 2.333\n");
printf("\nThis GPA should fall between 0 and 4.0 --> ");
scanf("%d, &numb1\n");
printf("\n*************************************************************\n");
printf("\nPlease enter the number of credit hours that this GPA was based");
printf("\n on. This should be a positive integer\n");
printf("\nFor example, for twelve credit hours, simple enter 12.\n");
printf("\n-->");
scanf("%d, &numb2");
printf("***************************************************************\n");
}
最佳答案
由于双引号的放置位置,您将向 scanf
传递一个参数。
应该是:scanf("%f", &numb1);
和 scanf("%d", &numb2);
请注意,numb1
是 %f
,因为它是 float ,numb2
是 %d
(对于整数)。
此外,您从未声明过变量 numb1
或 numb2
,因此您还需要: float numb1; int numb2;
位于函数顶部。
关于c - 程序没有显示错误,但无法编译。你能帮我解决我需要做的事情吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52320536/