나는 atm과 비슷한 것처럼 보이는이 작품을 가지고 있지만 내 문제는 균형을 업데이트하고 싶지만 나는 위선적이다. 예를 들어, 먼저 "0"을주는 잔액을 확인한 다음, "200"을 입금하면 잔액을 다시 확인할 때 "100"을 인출하려면 "200"을 입력하고 내가 균형을 점검 할 때 "100"을 주어야합니다. 하지만 난 함수의 값을 전달하는 문제가 있습니다. 여기 내 일이있다. 도와주세요. 오, 그건 그렇고, DEV C를 사용하여 메신저Turbo C의 가치 전달 기능
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
// Declaring Functions that exist in the program.
int menu();
// End
// Main method at top, just to help with readability. And it can use the functions since we have already told main they exist.
int main()
{
int a = 0;
int option;
int atmDeposit();
int atmWithdrawal(int balance);
int atmCheck(int z);
system("cls");
do
{
option = menu();
switch(option)
{
case 1:
atmDeposit();
break;
case 2:
atmWithdraw(a);
break;
case 3: atmCheck(a);
break;
case 4:
printf("\nGoodbye!");
system("pause");
exit(0);
default:
printf("\nInvalid!\n");
break;
}
}
while (option != 4);
getch();
return 0;
}
int menu()
{
int op;
system("cls");
printf("What do you want to do?: \n");
printf("1 - Deposit\n");
printf("2 - Withdraw\n");
printf("3 - Check Balance\n");
printf("4 - Exit\n\n");
printf("Enter Choice: ");
scanf("%d",&op);
return op;
}
// End
// to check balance
int atmCheck(int z)
{
printf("\nYour Balance is P%d\n",z);
system("pause");
return z;
}
// End check balance
// to Deposit
int atmDeposit()
{
int deposit, a=0;
printf("\nHow much money do you want to deposit?: P");
scanf("%d", &deposit);
a += deposit;
printf("%d",a);
system("pause");
return a;
}
// end deposit
// to withdraw
int atmWithdraw(int balance)
{
int withdraw;
printf("\nHow much money do you want to withdraw?: P");
scanf("%d", &withdraw);
balance -= withdraw;
printf("%d",balance);
system("pause");
return balance;
}
// end withdraw
입금 후 잔액을 확인할 때 200을 제공합니까? 그것은 나에게 0을 준다. –