J
jwatts
Hello group,
I am feeling pretty good about this program. I am just learning and
am trying to get the basics down. I would like to ask if someone
could tell me how to right justify the BALANCE column in my program's
output.
===============
Here is my code:
===============
#include <stdio.h>
int main (void)
{
int i;
int accountNumber[10];
char lastName[10][30];
float accountBalance[10];
printf("Enter account number, last name, and balance.\n");
printf("Enter -999 to end input.\n");
for (i = 0; i < 10; i++)
{
printf("? ");
scanf ("%i", &accountNumber);
if (accountNumber == -999)
{
printf("\n");
break;
}
scanf("%s", lastName);
scanf("%f", &accountBalance);
} /* End for loop */
printf("%-15s%-15s%-15s\n","ACCOUNT","LAST NAME","BALANCE");
for(i = 0; (i < 10) && (accountNumber != -999); i++)
{
printf("%-15d%-15s%-15.2f", accountNumber,
lastName, accountBalance);
printf("\n");
}
printf("\n\n");
return 0;
} /* End main */
I am feeling pretty good about this program. I am just learning and
am trying to get the basics down. I would like to ask if someone
could tell me how to right justify the BALANCE column in my program's
output.
===============
Here is my code:
===============
#include <stdio.h>
int main (void)
{
int i;
int accountNumber[10];
char lastName[10][30];
float accountBalance[10];
printf("Enter account number, last name, and balance.\n");
printf("Enter -999 to end input.\n");
for (i = 0; i < 10; i++)
{
printf("? ");
scanf ("%i", &accountNumber);
if (accountNumber == -999)
{
printf("\n");
break;
}
scanf("%s", lastName);
scanf("%f", &accountBalance);
} /* End for loop */
printf("%-15s%-15s%-15s\n","ACCOUNT","LAST NAME","BALANCE");
for(i = 0; (i < 10) && (accountNumber != -999); i++)
{
printf("%-15d%-15s%-15.2f", accountNumber,
lastName, accountBalance);
printf("\n");
}
printf("\n\n");
return 0;
} /* End main */