Code:
#include<stdio.h>
void main (void)
{
int num;
float bbal,tchar,tcred,credl,nbal;
printf("Enter account number (-1 to end):");
scanf("%d",&num);
while (num!=-1)
{
printf("Enter beginning balance: ");
scanf("%f",&bbal);
printf("Enter total charges: ");
scanf("%f",&tchar);
printf("Enter total credits: ");
scanf("%f",&tcred);
printf("Enter credit limit: ");
scanf("%f",&credl);
nbal=bbal+tchar-tcred;
{if (nbal>credl)
{ printf("Account:%d\n",num);
printf("Credit limit:%.2f\n",credl);
printf("Balance:%.2f\n",nbal);
printf("Credit limit exceeded.\n\n");
printf("\n\nEnter account number (-1 to end):");
scanf("%d",&num);}
else (nbal<credl)
{ printf("\n\nEnter account number (-1 to end):");
scanf("%d",&num);}
}
}
}
Problem is, wether nbal exceeds credl or not...it still follows the function of (nbal>credl), its ignoring else.... btw, this whole thing should repeat itself until account number is -1.
The result should come out just ask like its shown below if it exceeds or not. Thx! =)