程序未显示任何错误,但未编译。您能帮我解决这个问题的方法吗?
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");
}
答案 0 :(得分:2)
由于要在双引号中加上双引号,因此您正在向scanf
传递单个参数。
应为:scanf("%f", &numb1);
和scanf("%d", &numb2);
请注意,numb1
是%f
,因为它是浮点,而numb2
是%d
(对于整数)。
此外,您从未声明变量numb1
或numb2
,因此您还需要:float numb1; int numb2;
在函数顶部。