Question #39505
Write C++ function named customerCreditLimit()that accepts a double as a parameter
and displays the value as the amount of credit granted to a customer. Provide a default
value for the function so that if a program calls the function without using an argument,
the credit limit displays $500. Write a main()function that proves the function works
correctly, whether it is called with an argument or without.
1
Expert's answer
2017-03-27T10:12:58-0400
#include <stdio.h> #include <stdlib.h> #include <string.h>void customerCreditLimit( double val=500) /*default parameter*/ {         printf("$%5.3f\n",val); }int main ()  /* main function*/ {         char s[128];         printf ("enter amount of credit or 'e' for default: ");         scanf("%s",s);         if ( strcmp(s,"e") == 0 )                 customerCreditLimit(); /*print default value*/         else                  customerCreditLimit(atof(s)); /*print user value*/         system ("pause");         return 0;  }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS