WAP to illustrate working of default arguments. Calculate interest amount making use of default arguments.

/*
WAP to illustrate working of default arguments. Calculate interest amount
making use of default arguments.
*/
#include<iostream.h>
#include<stdlib.h>
void amount(float princ, int time = 2, float rate = 0.08); //prototype
void amount(float princ, int time, float rate)
{
      cout<<"\nPrincipal Amount: "<<princ;
      cout<<"\tTime: "<<time<<" years;";
      cout<<"\tRate: "<<rate;
      cout<<"\nInterest Amount: "<<(princ*time*rate)<<"\n";
}
int main()
{
      system ("cls");
      cout<<"Case 1";
            amount(2000);
      cout<<"Case 2";
            amount(2500, 3);
      cout<<"Case 3";
            amount(2300, 3, 0.11);
      cout<<"Case 4";
            amount(2500, 0.12);
      return 0;
}
OUTPUT



Comments

Popular posts from this blog

WAP using a class to store price list of 5 items and to print the largest prices as well as the sum of all prices.

WAP to get roll numbers and marks of the student of a class (get from the user) and store these details into a file called Marks.dat

WAP to create a single file and then display its contents.