+ 1
How to write a function argument program?
Write a program that has a function that takes a salary as an argument. If the salary is less than $20,000, give a 20% raise. Return the salary.
2 Respuestas
+ 13
double raise(double salary) {
if (salary<20000) {
return salary*1.2;
}
return salary;
}
0
#include<iostream>
using namespace std;
int func(int salary){
if (salary < 20000){
salary += (salary*20) / 100;
return salary;
}
else {
return salary;
}
}
int main(){
int sal;
cout<<"Enter your salary: ";
cin>>sal;
func(sal);
return 0;
}