Error in output:some unknown characters printed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • priyankakhabiya
    New Member
    • Aug 2012
    • 1

    #1

    Error in output:some unknown characters printed

    Code:
    #include<stdio.h>
    #include<conio.h>
    struct name
    {
     char initial[5];
     char first_name[10];
     char middle_name[10];
     char last_name[10];
    };
    struct address
    {
     int house_no;
     char street_name[10];
     char city[10];
     char state[10];
    };
    struct bank_acc
    {
     int acc_no;
     struct name cust_name;
     struct address cust_add;
     float phone_no;
     float balance;
    }account[50];
    int no_of_acc=0;
    void create();
    void display(int);
    void withdraw();
    void deposit();
    void main()
    {
     int choice;
     char ch;
     do
     {
     clrscr();
     printf("MENU\n\n");
     printf("1.CREATE\n");
     printf("2.DISPLAY\n");
     printf("3.WITHDRAW\n");
     printf("4.DEPOSIT\n");
     printf("ENTER YOUR CHOICE : ");
     scanf("%d",&choice);
     switch(choice)
     {
     case 1 :
    		create();
    		break;
     case 2 :
    	{
    		int acc_num;
                    printf("ENTER YOUR ACCOUNT NUMBER\n");
                    scanf("%d",&acc_num);
    		display(acc_num);
    		break;
    	}
     case 3 :
    		withdraw();
    		break;
     case 4 :
       		deposit();
    		break;
     default :
    		printf("WRONG CHOICE!!!!\n");
     }
     printf("DO YOU WANT TO CONTINUE : ");
     fflush(stdin);
     scanf("%c",&ch);
    }while(ch=='y'||ch=='Y');
    getch();
    }
    void create(int no_of_acc)
    {
     int i = no_of_acc;
     float amt;
    
     printf("ENTER CUSTOMER DETAILS\n\n");
     printf("ENTER NAME\n");
     printf("INITIAL : ");
     scanf("%s",account[i].cust_name.initial);
     printf("\nFIRST NAME : ");
     scanf("%s",account[i].cust_name.first_name);
     printf("\nMIDDLE NAME : ");
     scanf("%s",account[i].cust_name.middle_name);
     printf("\nLAST NAME : ");
     scanf("%s",account[i].cust_name.last_name);
     printf("\n\nENTER ADDRESS\n\n");
     printf("ENTER HOUSE NO : ");
     scanf("%d",&account[i].cust_add.house_no);
     printf("\nENTER STREET NAME : ");
     scanf("%s",account[i].cust_add.street_name);
     printf("\nENTER CITY : ");
     scanf("%s",account[i].cust_add.city);
     printf("\nENTER STATE : ");
     scanf("%s",account[i].cust_add.state);
     printf("ENTER THE AMOUNT YOU WANT TO DEPOSIT\n");
     scanf("%f",&amt);
     if(amt<500)
     {
    	printf("MINIMUM BALANCE OF 500 REQUIRED\n");
    	printf("\nCANNOT CREATE ACCOUNT");
     }
     else
     {
    	account[i].acc_no=12345+i;
    	account[i].balance=amt;
    	no_of_acc++;
     }
    }
    void display(int acc_num)
    {
     int i;
     for(i=0;i< no_of_acc;i++);
     {
    	if(account[i].acc_no==acc_num)
    	{
    	  printf("CUSTOMER DETAILS\n\n");
    	  printf("NAME\n");
    	  printf("%s ",account[i].cust_name.initial);
    	  printf("%s ",account[i].cust_name.first_name);
    	  printf("%s ",account[i].cust_name.middle_name);
    	  printf("%s ",account[i].cust_name.last_name);
    	  printf("\n\nADDRESS\n\n");
    	  printf("%d ",account[i].cust_add.house_no);
    	  printf("%s ",account[i].cust_add.street_name);
    	  printf("%s ",account[i].cust_add.city);
    	  printf("%s ",account[i].cust_add.state);
    	  printf("\nYOUR PRESENT BALANCE IS RS.%f",account[i].balance);
    	 }
     }
     if(i==no_of_acc)
     {
      printf("\nTHIS ACCOUNT NUMBER DOES NOT EXIST\n");
     }
    }
    
    void withdraw()
    {
     float wd;
     int acc,i;
     printf("ENTER YOUR ACCOUNT NUMBER\n");
     scanf("%d",&acc);
     for(i=0;i<no_of_acc;i++)
     {
       if(acc==account[i].acc_no)
       {
        display(acc);
        printf("\nENTER AMOUNT OF MONEY YOU WANT TO WITHDRAW : RS.");
        scanf("%f",&wd);
        if(account[i].balance-wd<500)
        {
           printf("\nNOT SUFFICIENT BALANCE\n");
           printf("\nMINIMUM BALANCE OF 500 REQUIRED\n");
        }
        else
        {
            account[i].balance=account[i].balance - wd;
        }
        display(acc);
       }
     }
    }
    void deposit()
    {
     int acc,i;
     float deposit;
     printf("ENTER YOUR ACCOUNT NUMBER\n");
     scanf("%d",&acc);
     for(i=0;i<no_of_acc;i++)
     {
       if(acc==account[i].acc_no)
       {
         display(acc);
         printf("ENTER THE AMOUNT YOU WANT TO DEPOSIT\n");
         scanf("%f",&deposit);
         account[i].balance=account[i].balance+deposit;
         display(acc);
       }
     }
    }
    problem:when do you want to continue is asked den with menu some unknown characters are printed
    Last edited by weaknessforcats; Aug 10 '12, 04:36 PM. Reason: added code tags
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    This is an excellent time to learn now to step through your code using your debugger. You need to verify the program is doing what you think it is.

    Comment

    Working...