hi !
can someone help me with the printf alignment
when i run the code below , compare with price = 5 and price=50
the alignment is like
$5.00
$50.00
how do i change my code , so the alignment is like
$5.00
$50.00
code
__________________________________________________ __
#include<stdio.h>
int main(void){
float price = 5;
int quantity =3;
static char *documentfmt = "%-40s %8s %10s %10s\n";
printf(documentfmt, "Product Name", "Quantity", "Unit Cost", "Subtotal");
printf("-----------------------------------------------------------------------\n");
printf("%49d",quantity);
printf("%6s%.2f\n","$",price);
return 0;
}
__________________________________________________ __