#include <iostream> |
Volume of a box with |
double tax(double income, bool married = false, int
dependent = 0, bool resident = true);. double tax(double income, bool&
married = false);double calculateGPA(char grade = 'A', int unit = 4);double calculateInterest(double balance, double
interestRate = 0.05);void showVolume(int length = 1, int width, int height);double double tax(double income, bool married = false,
int dependent, bool resident = true)double tax(double income, bool married = false, int dependent = 0);incorrect
double tax(double income, bool married = false, int dependent = 0) {
// function body
}
The correct version should be
double tax(double income, bool married, int dependent) {
// function body
}
Function body
double tax(double income, bool married = false, int dependent = 0, bool
resident = true);
| Function call | Meaning |
tax(100000,true,2,false) |
tax(50000,true,2,false) |
tax(200000,true,3) |
tax(200000,true,3,true) |
tax(75555,false,2) |
tax(75555,false,2,true) |
tax(22333.75,true) |
tax(22333.75,true,0,true) |
tax(35678.25) |
tax(35678.25,false,0,true) |
resident, you must provide the
value for
married and dependent.
#include <iostream> |
#include <iostream> |
Please input 5 numbers. Seperate the numbers by spaces: |
score[0] |
score[1] |
score[2] |
score[3] |
score[4] |
| 92.25 | 33 | 45.75 | 88.8 | 77.77 |
| Declare an array Type arrayName[size]; size should be a number or a const variable. It shouldn't be other type of variables. |
int year[50];int is called the base type of the array,
50 is the size. year is the name.
double taxRate, income[99];The order doesn't matter.
#include <iostream> |
#include <iostream> |
score[0],score[1],score[2],score[3],score[4]
represent the first, second, third, forth and fifth element in the
array scorescore[i] as variables. i.e. you can
use it in assignments, arithmetic expression etc etcscore[i],
or income[n+1].