60 438
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #39505 in C++ for Verasak Sitawan

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions