Hello, I can't line up my columns in my code. The code looks okay, and is lined up, but the output is not lined up. What can I do to fix it?
As you can see in my code, unit price and purchase date are lined up vertically. But they don't come out okay in the execution of the program.
Thanks! I'm not sure if I'm supposed to use m for minimum field width or integers with - symbols? If so, how do I do it with my code? I used tab stops in writing my code, which looks perfect on the code, but not when the progra is run. Thanks
As you can see in my code, unit price and purchase date are lined up vertically. But they don't come out okay in the execution of the program.
Thanks! I'm not sure if I'm supposed to use m for minimum field width or integers with - symbols? If so, how do I do it with my code? I used tab stops in writing my code, which looks perfect on the code, but not when the progra is run. Thanks
Code:
#include <stdio.h>
main ( )
{
int item ;
float price ;
int month ;
int day ;
int year ;
printf ("Enter item number: ") ;
scanf ("%d", &item ) ;
printf ("Enter unit price: ") ;
scanf ("%f", &price) ;
printf ("Enter purchase date (mm/dd/yy): ") ;
scanf ("%d/%02d/%d", &month, &day, &year) ;
printf ("Item: Unit Purchase\n" );
printf (" Price Date\n" ) ;
Printf ("%d", "%f", "%02d", item, price, month, day, year) ;
return 0 ;
/*program output below*/
Enter item number: 99
Enter unit price: 99.99
Enter purchase date (mm/dd/yy): 11/09/91
Item Unit Purchase
Price Date
}
Last edited by a moderator: