-
Need a function
How do i make a function that uses this statement:
cout << "Enter 4 positive number: "<<endl;
for( x = 0; x < north; x++)
cin >> north;
cin >> south;
cin >> east;
cin >> west;
cout <<'*';
I am not allowed to use assigment statements, only function calls. I don't know how to do that with a statement that isn't mathamatic. I know there is probably a better way to write the above statement, possibly using a loop. But i am really stuck on how to creat a function
Anyone who can help, I would very much appreciate it.
-
Could you post the exact assignment.
-
try this
#include<iostream.h>
int get_numbs(); //prototype
int get_numbs() // the function
{
int x;
int y = 5;
static int array[4];
cout << "Enter 4 positive number: "; //tell them what to do
for( x=1; y > x; x++) // run this four times to get numbers
{
cout << "\n Enter number " << x << " ";
cin >> array[x];
}
// print out the numbers to the screen
cout << "\n\nNumber 1 Equals "
<< array[1] << " \nNumber 2 Equals "
<< array[2] << " \nNumber 3 Equals "
<< array[3] << " \nNumber 4 Equals "
<< array[4] << "\n\n\n";
return 0; //done, go back to main
}
int main(void) // the main returns an int and has no arguments
{
get_numbs(); //call the function get_numbs()
return 0; // send this to the OS, good bye
}