hi there i am new to this forum and very new to c programming
i do need any of u guyzz there to help me with my assignment
i need to do a simple bank program asking the user password at first with the menu:
1. withdraw
2. balance enquiry
3. change password
4. exit
and i do need to know how to declare clrscr();
i dont know hot to clear screen, how to exit, and when a user selects a menu..... he must return to the main containing the the above thing, and i dont even know how make the change in password coz i use if statement for my password.... is there any other way?

this is my coding... i havent done much but plz help me
and i hope u guyz can help me fast with this

#include<stdio.h>
int password,menu,new_password;
float balance,withdraw,withdraw_after;
main()
{
 printf("PLEASE ENTER YOUR PASSWORD:\t");
 scanf("%d",&password);
 
  if(password==123456)
  {
   balance=1500;
   printf("MENU SCREEN\n");
   printf("1. Withdraw\n");
   printf("2. Balance Enquiry\n");
   printf("3. Change Password\n");
   printf("4. Exit\n\n");
   printf("Select A Menu:\t");
   scanf("%d",&menu);
    switch(menu)
    {
    case 1:
     printf("Withdraw Menu\n\n");
     printf("User Name:\t Tony");
     printf("Account Balance:\t RM %.2f",balance);
     printf("Enter The Amount You Want To Withdraw:\t");
     scanf("%f",&withdraw);
     
      if(withdraw>balance)
      {
       printf("You Don't Have Enough Money In Your Account");
      }
      else
      {
       withdraw_after=balance-withdraw;
       printf("You Have RM %.2f Left In Your Account",withdraw_after);
      }
    break;
    case 2:
     printf("Balance Enquiry Menu\n");
     printf("User Name:\t Tony");
     printf("Account Balance:\t RM %.2f",balance);
    break;
    case 3:
     printf("Change Password Menu");
     printf("Please Enter A New Password:\t");
     scanf("%d",new_password);
     password=new_password;
    break;
    case 4:
    break;
      
    }
  }
}
Member Avatar for iamthwee

>and i do need to know how to declare clrscr();
This is unnecessary.

All your problems would be solved if you drew a flow chart to summarise your problem. Have you done this?

It is better if you use characters for the menu instead of numbers.
Here it is the skeleton of a menu you can use. I made use of the first character of every option as the one the user can choose from.

#include <stdio.h>
#include <ctype.h>

#define FALSE 0
#define TRUE !FALSE

int main( void )
{
    int c;
    int done = FALSE;
    
    while( !done )
    {
           puts("\nMENU SCREEN\n");
           puts("W - Withdraw\n");
           puts("B - Balance Enquiry\n");
           puts("C - Change Password\n");
           puts("Q - Quit\n");
           fputs("Select a choice: ", stdout );
           fflush( stdout );
           
           c = getchar();
           c = toupper( c );
           
           switch( c )
           {
            case 'W':
            /* do something here */
                break;
            case 'B':
            /* do something here */    
                break;
            case 'C':
            /* do something here */    
                break;
            case 'Q':
                done = TRUE; /* Exit here */
                break;
            default:
                puts( "Wrong input, choose again" );
                break;
        }
    }
}
commented: #define True != False (Ha ha) +10

It is better if you use characters for the menu instead of numbers.
Here it is the skeleton of a menu you can use. I made use of the first character of every option as the one the user can choose from.

thx 4 the reply man
but there is a prob here man....
at first the program should ask for a password.....
from the password it will determine which account of the user it should open and access..... for example there is 2 user.... 1 wit 1200 balance and 1500 balance.... and the passwords are 123 and 456 for the two users..... when we key in password as 123 it will access the user wit 1200 balance... and if we key in 456 it will accesss the balance 1500...
from there i dont know how to save the balance into the source code...
i cant keep the info in a file cozzz my assignment doesnt let me do it....
is there a way to modify a way to..... for example when the first time i access the account the balance is 1200... and then i take out 200 and there are 1000 left.... without saving the info in a file how to save the new balance so tat when i open again the balance is 1000 or should it b done by saving the balance into file...... if save it into a file... how to do it?

>and i do need to know how to declare clrscr();
This is unnecessary.

All your problems would be solved if you drew a flow chart to summarise your problem. Have you done this?

thx 4 the reply man
i dont really have the flow chart but i know hot the output must come out.... the problem is i dont know how to modify the passsword, the balance and how to save it... refer to my reply to Aia

1. from there i dont know how to save the balance into the source code...
2. i cant keep the info in a file cozzz my assignment doesnt let me do it....
3. without saving the info in a file how to save the new balance so tat when i open again the balance is 1000 or should it b done by saving the balance into file......
4. if save it into a file... how to do it?

1. There 2 basic requirements for storage, A) Temporary B) Persistent.
- Temporary can be achieved using teh structures or arrays or variables (depending on what you wanna store). This would remain in the program memory and be wiped off when you restart your program.
- Persistent can be achieved using many ways e.g. file, database, tape-drive, shared-memory (NOT same as program memory) etc. Again what you choose depends on requirements. E.g. shared memory is very fast, whereas DB will provide you all kind of querying so you don't have to write code for that.
2. If this is the case it's clear that you don't have a requirement to keep data persistently. So go ahead and use one of the temporary methods. I would suggest use a structure.
3. Think a li'l on how to keep data in structures and you'll figure this out.
4. Do you want/need to store data in file or not ?

please teach how to make a code in turbo C! it is our project.... about DENOMINATION of number.... pls. teach me some simple programs....

commented: You guys are annoying as hell +0

i would like you to create your own thread to ask questions and not to use others thread. And as for your answer try to read book " Let us c " by Yashwantrao Kanetkar
Its very good book in simplified language best for beginners.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.