C Programming ATM Machine Project Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fumbles
    New Member
    • Apr 2010
    • 2

    C Programming ATM Machine Project Issue

    Hello, and let me first start off by saying thanks for taking the time to read this.
    I have a program just about made up. It compiles almost all the way. Can a.out to an extend, only issue at the moment is
    Code:
    Line 42: Statement Not Reached
    And I am quite stumped as to what it is I need to do to fix this.

    Here is the program so far.
    Code:
    #include<stdio.h>
    
    #include<stdlib.h>
    
    int main()
    {
    char option, pin, transaction;
    
    int deposit, withdraw;
    
    option='0';
    
        printf("Welcome To Ian's Bank!\n");
        printf("----------------\n\n");
        printf("Main Menu\n");
        printf("----------------\n");
        printf("1)Enter Pin #\n");
        printf("2)Exit\n");
        printf("----------------\n\n");
        scanf("%c", &option);
    
        {
        system("cls");
        printf("Pin Number Verification\n");
        printf("----------------\n\n");
        printf("Please Enter Your Pin Number: ");
        scanf("%s", &pin);
    
       //if(inputfile ==NULL)
        {
        printf("Unable to open input file\n");
        }
        return 1;
        {
        system("cls");
        printf("Transactions\n");
        printf("---------------\n");
        printf("1)Deposit\n2)Withdraw\n3)Statement\n4)Exit\n");
        printf("---------------\n");
        scanf("%s",&transaction);
        } 
        }
    
        if(transaction =='1')
        {
        system("cls");
        printf("Deposit\n");
        printf("-------------\n\n");
        printf("Please enter the amount of money you would like to deposit:");
        scanf("%d", &deposit);
        }
    
        if(transaction=='2')
    
        {
        system("cls");
        printf("withdraw\n");
        printf("---------------\n\n");
        printf("Please enter the amount of money you would like to withdraw:");
        scanf("%d", &withdraw);
        }
    
        if(transaction=='3')
        {
        system("cls");
        printf("Statement\n");
        printf("----------------\n\n");
        }
    
    
        return 0;
    
        }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    This code:

    Code:
    //if(inputfile ==NULL) 
        { 
        printf("Unable to open input file\n"); 
        } 
        return 1;
    has the printf inside an anonymous code block making the return -1 the return from main().

    I think you meant the return -1 to be inside the the braces underneat the printf.

    And you will bne to active the the if statement by removing the //

    Comment

    • Fumbles
      New Member
      • Apr 2010
      • 2

      #3
      And there we go. Nice, working, and ready for the last steps of adding arrays. Thank you so much for your help there! I really appreciate it!

      Comment

      Working...