void getInput(double sal[][2], int numEmps);
void findUnluckies(double sal[][2], int numEmps, int lucky[]);
void markIfUnlucky(double sal[][2], int numEmps, int lucky[], int upperBound, int empNbr);
just tell me is there any hard n strict rule of writing a function???Like here's a function named getInput ...there is 1 array n 1 variable..If I would write this function how I'll get an idea I need 1 array n 1 variable??
A function is a collection of instructions.
What you posted in your first post aren't functions. They're declarations of functions (names).
This is a function:
1 2 3 4 5 6
int function1(char a) // this is the name but notice how it doesn't end with semicolon ;
{
// this is the body of the function, which contains the instructions, in the desired order
std::cout << a << std::endl;
return 1;
}
In layman's terms, it's a group of instruction statements that are executed once the function is invoked (called). The code you posted are function prototypes; a requirement in C++. Prototype functions are function interfaces that describe the datum returned, parameters, and symbol. Prototypes omit the body until a later time.
Can someone explain these bold lines const int arraySize=100;
double sal[arraySize][2];
int lucky[arraySize] = {0};
int numEmps;
cout << "\n Please enter the total number of employees in your company: ";
cin >> numEmps;
cout<<'\n';
getInput(sal, numEmps);
#include <iostream.h>
void getInput(double sal[][2], int numEmps);
void calcNetSal(double sal[][2], int numEmps);
void findUnluckies(double sal[][2], int numEmps, int lucky[]);
void markIfUnlucky(double sal[][2], int numEmps, int lucky[], int upperBound, int empNbr);
void printUnluckies(int lucky[], int numEmps);
main()
{
const int arraySize=100;
double sal[arraySize][2];
int lucky[arraySize] = {0};
int numEmps;
cout << "\n Please enter the total number of employees in your company: ";
cin >> numEmps;
cout<<'\n';
getInput(sal, numEmps);
void getinp(double sal[][2], int numEmps)
{
for (int i = 0; i < numEmps; i++)
{
cout << "\n Please enter the gross salary for employee no." << i << ": ";
cin >> sal[i][0];
}
}
cout << "\n\n Calculating the net salaries...";
calcNetSal(sal, numEmps);
This is function call. More specifically, an invocation of getInput( ). During the invocation, two arguments are copied into the corresponding parameters of getInput( ).