Hey guys! I'm new to all of this and i was hoping that someone would be able to assist me with an issue i have with this program.
Code:
#include <stdio.h>
main()
{
int ctr;
int idSearch;
int found = 0;
int custID[10] = {313, 453, 502, 101, 892, 475, 792, 912, 343, 633 };
float custBal[10] = { 0.00, 45.43, 71.23, 301.56, 9.08, 192.41, 389.00, 229.67, 18.31, 59.54};
int tempID, inner, outer, didSwap;
float tempBal;
for (outer = 0; outer < 9; outer++)
{
didSwap = 0;
for(inner = outer; inner < 10; inner++)
{
if (custID[inner] < custID[outer])
{
tempID = custID[inner];
tempBal = custID[inner];
custID[inner] = custID[outer];
custBal[inner] = custBal[outer];
custID[outer] = tempID;
custBal[outer] = tempBal;
didSwap = 1;
}
}
if (didSwap == 0)
{
break;
}
}
printf("\n\n*** Cutomer Balance Lookup ***\n");
printf("What is the customer number? ");
scanf(" %d, &idSearch");
for (ctr=0; ctr<10; ctr++)
{
if (idSearch == custID[ctr])
{
found = 1;
break;
}
if (custID[ctr] > idSearch)
{
break;
}
}
if (found)
{
if (custBal[ctr] > 100.00)
{
printf("\n*** That customer's nBalance is $%.2f.\n", custBal[ctr]);
printf(" No credit!\n");
}
else
{
printf("\n**The customer's credit is ggood!\n");
}
}
else
{
printf("**You must have typed an incorrect cusomer ID.");
printf("\n ID %3d was not found in list. \n", idSearch);
}
return 0;
}
I'm currently using code blocks for this and when i run this program there is absolutely no syntax errors. However, the moment you type something in and hit enter the program stops and a screen comes up saying that there is something wrong with the program and then it dies. It's really sad but i would really appreciate it if someone could give me some advice on what could possibly be the problem. Thank you!