fork download
  1. #include <stdio.h>
  2.  
  3. #define SIZE 10
  4.  
  5. int main(void)
  6. {
  7. double amount;
  8. char amountString[SIZE];
  9.  
  10. printf("Enter a dollar amount: ");
  11. scanf("%lf", &amount);
  12.  
  13. sprintf(amountString, "%.2f", amount);
  14.  
  15. int length = 0;
  16.  
  17. while (amountString[length] != '\0')
  18. {
  19. ++length;
  20. }
  21.  
  22. int stars = SIZE - 1 - length;
  23.  
  24. if (stars < 0)
  25. {
  26. stars = 0;
  27. }
  28.  
  29. printf("Check-protected amount: ");
  30.  
  31. for (int i = 0; i < stars; ++i)
  32. {
  33. printf("*");
  34. }
  35.  
  36. printf("%s\n", amountString);
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5348KB
stdin
Standard input is empty
stdout
Enter a dollar amount: Check-protected amount: *****0.00