Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write code to assign to the variable format a formatting string that will displa

ID: 671477 • Letter: W

Question

Write code to assign to the variable  format a formatting string that will display three values referenced by the variables  quantity (type int),description (type str), and unitPrice (type float) in the format illustrated by: (type "_10 One-inch Three-ring binder_____________ $___5.50"). The quantity is displayed right-justified in 3 print positions, the description is displayed left-justified in 30 print positions, and the amount is displayed after a dollar sign with a total of 7 print positions and two digits after the decimal point. In the example, an underscore character is used to indicate the presence of a filler space. The underscores are not part of the actual string.

Explanation / Answer

working c code

#include<stdio.h>
#include<stdlib.h>
#include<string>
int main()
{
   int quantity = 10;
   static char description[] = "One-inch Three-ring binder";
   float unitPrice = 5.50;
   printf("%3d %-30s $ %7g",quantity,description,unitPrice);
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote