Ok so this is an extra credit lab i have for any missed lab or replace for our lowest lab score for anyone has in the class. I'm not sure what im suppose to do with it the teacher just emailed us this info. If anyone can direct me to what im suppose to be writing about would be appreciated, lab is due wednesday, so ill be posting updates on what i have done

#include <iostream>
#include <iomanip>

using namespace std;

//prototypes for functions for lab10
int empty_array_insert(int[], int);
void display_in_reverse(int[], int);

void main()
{

	//local constants
	const int SIZE = 5;

	//local variables
	int Numbers[SIZE];   //array to store input values
	int Count;           //number of values in the array

	/***********************************************************/

	//call function to input numbers into the empty array
	Count = empty_array_insert(Numbers, SIZE);

	//clear the screen
	system("cls");

	//display the values in the array
	cout << "/n/n/n";
	cout << setw(43) << "Numbers" << endl;
	cout << setw(43) << "-------" << endl << endl;
    display_in_reverse(Numbers, Count);

}//end main

/*** put your functions (with prologues) here **************/

Edited 7 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

Looks like your inputting numbers in an array and then displaying them in reverse?

Based on what you have there, I suspect you're supposed to write the two functions:

int empty_array_insert(int[], int);
void display_in_reverse(int[], int);

Since this is your first post, please read about code tags and learn to use them if you want people to read your code.

Read About Code Tags Here

There are some forum rules which can help you get good answers, much quicker.

whoa ok so step by step i havnt yet learned how to display array in reverse and we are still in the process in learning how functions work...

so first i...

-declare array
-make a function for the array to put the numbers in
-make another function to display the array in reverse
-end

??

The basic code you were given declares the array and then passes it to the functions you are supposed to write.

The basic code you were given declares the array and then passes it to the functions you are supposed to write.

ohh ok so in my code it will have all that info and i just write the code under the functions, ok, ill attempt that now and post my results. may have a few questions in a bit

is the max array size for this question 5?

In this example, yes. But that makes no difference for the functions you are supposed to write.

ok so for the first function is to get numbers into the array (which is suppose to 5 numbers)

i have this please tell me if i have any mistakes in this ....

while (int count = 0; count < 5; count ++)
cout << "Enter a number" << endl;
cin  >> empty_array_insert ;

ok so for the first function is to get numbers into the array (which is suppose to 5 numbers)

i have this please tell me if i have any mistakes in this ....

while (int count = 0; count < 5; count ++)
cout << "Enter a number" << endl;
cin  >> empty_array_insert ;

As I mentioned...

In this example, yes. But that makes no difference for the functions you are supposed to write.

You don't want to hard-code the 5.

It's supposed to be the second parameter to the function. Just copy and paste the whole dang function. The missing information is important, you know -- snipping and paraphrasing code isn't doing you any favors.

Edited 7 Years Ago by Dave Sinkula: n/a

As I mentioned...

You don't want to hard-code the 5.

It's supposed to be the second parameter to the function. Just copy and paste the whole dang function. The missing information is important, you know -- snipping and paraphrasing code isn't doing you any favors.

ok i switched the 5 like you said, i forgot that is a rule, so i have it as SIZE. can anyone tell me how im suppose to display the array in reverse? and if my while function is in the right spot?

#include <iostream>
#include <iomanip>

using namespace std;

//prototypes for functions for lab10
int empty_array_insert(int[], int);
void display_in_reverse(int[], int);

void main()
{

//local constants
const int SIZE = 5;

//local variables
int Numbers[SIZE]; //array to store input values
int Count; //number of values in the array

/***********************************************************/

//call function to input numbers into the empty array
Count = empty_array_insert(Numbers, SIZE);

//clear the screen
system("cls");

//display the values in the array
cout << "/n/n/n";
cout << setw(43) << "Numbers" << endl;
cout << setw(43) << "-------" << endl << endl;
display_in_reverse(Numbers, Count);

}//end main

/*** put your functions (with prologues) here **************/



while (int count = 0; count < SIZE; count ++)
cout << "Enter a number" << endl;
cin  >> empty_array_insert ;

No. You'll need to take a stab at writing a function. Prototypes (lacking parameter names) were provided.

A function looks like this:

void foo()
{
}

(Yours will look more like the prototype.)

[edit]

ok i switched the 5 like you said, i forgot that is a rule, so i have it as SIZE.

Uh...

It's supposed to be the second parameter to the function.

Edited 7 Years Ago by Dave Sinkula: n/a

No. You'll need to take a stab at writing a function. Prototypes (lacking parameter names) were provided.

A function looks like this:

void foo()
{
}

(Yours will look more like the prototype.)

[edit]Uh...

Okay, work with me here please.

i made a change here

int empty_array_insert(int[], int)

//Numbers entered in array
while (int count = 0; count < SIZE; count ++)
cout << "Enter a number" << endl;
cin  >> empty_array_insert ;

and this is the whole code..

#include <iostream>
#include <iomanip>

using namespace std;

//prototypes for functions for lab10
int empty_array_insert(int[], int);
void display_in_reverse(int[], int);

void main()
{

//local constants
const int SIZE = 5;

//local variables
int Numbers[SIZE]; //array to store input values
int Count; //number of values in the array

/***********************************************************/

//call function to input numbers into the empty array
Count = empty_array_insert(Numbers, SIZE);

//clear the screen
system("cls");

//display the values in the array
cout << "/n/n/n";
cout << setw(43) << "Numbers" << endl;
cout << setw(43) << "-------" << endl << endl;
display_in_reverse(Numbers, Count);

}//end main

/*** put your functions (with prologues) here **************/


int empty_array_insert(int[], int)

//Numbers entered in array
while (int count = 0; count < SIZE; count ++)
cout << "Enter a number" << endl;
cin  >> empty_array_insert ;

also how am i suppose to display an array in revers??

>i made a change here
The curly braces are not optional. Do you ever try compiling?

>int empty_array_insert(int[], int)
I thought I mentioned that you'll need to give the parameters names. This is in order for you to use them. And then when you have these names that you've created to use, you can use it instead of SIZE, which I never said to use.

>also how am i suppose to display an array in revers??
Baby steps, I'm afraid.

This article has been dead for over six months. Start a new discussion instead.