Search This Blog

Friday 3 June 2016

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



No comments:

Post a Comment

How do I crack the GSOC in the field of machine learning?

How do I crack the GSOC in the field of machine learning? Working as a student at Google Summer of Code demands for your dedication an...