Ok, well lets take a quick look at your original code. I have quoted your original post because it includes the full code and your original post where you gave some good example values. Your full post is below:
Hi there,
Kindly see my attached code below. This is already running however, I do have a little problem with the WITHDRAWAL part.For example:
My current balance is 500 and I withdraw 501. It will tell me at first that I have insufficient funds and would prompt me to enter another amount. However, If I enter 501. It will tell me that I have -1 as my New balance which should't be. What I want is it will keep me prompting an mount either less than or equal to my current balance so that it will not display a negative new balance.#include <stdio.h> #include <stdlib.h> int dep=0,ab=0,wdraw=0; void acctbal() { printf ("\n\n---Account Balance---\n\n"); printf ("\n\nYour Current Balance is: %d\n\n",ab); } void deposit () { printf ("\n\n---Deposit---\n\n"); printf ("Enter Amount :"); scanf ("%d",&dep); ab=ab+dep; printf ("\n\nAmount deposited: %d",dep); printf ("\nNew Balance: %d\n\n",ab); } void withdraw () { if (ab==0) { system("ds"); printf ("\n\nplease be reminded that your current balance is: %d\n", ab); return; } else { printf ("\n\n--Withdraw--\n\n"); printf ("Enter Amount :"); scanf ("%d", &wdraw); } if (ab>=wdraw) { ab=ab-wdraw; printf ("\n\nAmount withdraw: %d",wdraw); printf ("\nNew balance: %d\n\n", ab); } else { printf ("\n\n Insufficient Funds--\n"); printf ("please be reminded that your current balance is: %d\n",ab); printf …