은행프로그램 만들기

조회수 498회

지역함수만을 사용하여 이식이 작동하게 할 수 있나요?

int deposit(int money);
int whitdraw(int money);
void balanceOutput(void);

int main(void)
{
    int balance = 0;
    int choice;

    while (1)
    {
        printf("\n1) 입금 \n");
        printf("2) 출금 \n");
        printf("3) 잔고조회 \n");
        printf("4) 종료 \n");

        do {
            printf(" 선택하세요 ? (1~4) ");
            scanf("%d", &choice);
        } while (choice < 1 || choice>4);

        switch (choice)
        {
        case 1: deposit(balance);
            break;
        case 2: whitdraw(balance);
            break;
        case 3: balanceOutput(balance);
            break;
        case 4: puts("프로그램을 종료합니다");
            exit(0);
        }
    }
    return 0;
}

int deposit(int balance)
{
    int money;

    printf("\n입금할 금액은?");
    scanf("%d", &money);
    balance = balance + money;

    return balance;
}
int whitdraw(int balance)
{
    int money;

    printf("\n출금할 금액은 ? ");
    scanf("%d", &money);

    if (money > balance)
        printf("잔고 부족 \n");
    else
        balance = balance - money;

    return balance;
}
void balanceOutput(balance)
{
    printf("현재 잔고는 : %d 입니다. \n", balance);
}

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)