I'm making a simple program that gets the users balance from the entered ID. For some reason the for loop doesn't execute when an ID from the listof_ID array is entered:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
int cntr;
int ID;
int listof_ID[] = {001, 002, 003, 004, 005};
float listof_BAL[] = {338.90, 745.87, 897.32, 665.36, 102.45};
puts("**Check Your Balance** \n");
printf("**Please Enter Your ID >> ");
scanf("%d", &ID);
for(cntr = 0; cntr > 5; cntr++)
{
if(ID == listof_ID[cntr])
{
puts("Your balance is ");
printf("%.2f", listof_BAL[cntr]);
break;
}
}
return 0;
}
listof_ID[]with octal literals? In this case it won't matter, but still, it seems as though you are probably unaware of this.std::cout << 0010; // prints "8". All it takes is one leading zero, the rest are irrelevant.