我正在尝试运行以下程序..但它最后一直给我错误..似乎我忘记关闭一个循环左右..如果有人能够帮助我,那就太好了! !
#include <stdio.h>
#include <math.h>
main () {
//variables
int user_selection, count_donate=0, count_invest=0;
float balance_of_fund, donate_amt, invest_amt;
//input
printf("Welcome!\n");
printf("What is the initial balance of the fund?\n");
scanf("%f", balance_of_fund);
//provide user with options
printf("What would you like to do?\n 1 - Make a donation\n 2 - Make an investment\n 3 -
Print balance of fund\n 4 - Quit\n");
//work with user selectiom
scanf ("%d", user_selection);
if (user_selection > 0 && user_selection < 4) {
//ask for donation amount
for (user_selection = 1; user_selection<=1; user_selection++) {
printf("How much would you like to donate?\n");
scanf("%f", donate_amt);
balance_of_fund = balance_of_fund + donate_amt;
count_donate++;
}
//ask for investment amount
for (user_selection = 2; user_selection<=2; user_selection++) {
printf("How much would you like to invest?\n");
scanf ("%f", invest_amt);
balance_of_fund = balance_of_fund - invest_amt;
count_invest++;
}
//print out final balance for selection 3
for (user_selection = 3; user_selection<=3; user_selection++) {
printf("The final balance is $%.2f.", balance_of_fund);
printf("There were %d donations and %d investments.",count_donate, count_invest);
}
//Quit for selection 4
else if (user_selection = 4) {
printf("The final balance is $%.2f." ,balance_of_fund);
}
else {
printf("Please make a valid selection");
}
return 0;
如果您有任何建议,请告诉我.. 在这一点上,我不确定我做错了什么