Array into function as parameter pass

Hey everyone, so I have been working on this all day, and its due in like an hour and a half. I have done everything the program wants except the last part. Here is the assignment:

Write a program that inputs 10 integers from the console into an array, and removes the duplicate array elements and prints the array. You may assume that all the integers are between 0 and 100, Write at least 1 function in addition to the main function, and pass an array into that function as a parameter. e.g.

Please enter your 10 numbers: 1 2 3 4 5 6 7 8 9 10
The array contains: 1 2 3 4 5 6 7 8 9 10

Please enter your 10 numbers: 1 1 3 3 3 6 7 8 9 9
The array contains: 1 3 6 7 8 9

Please enter your 10 numbers: 1 1 1 1 1 1 1 1 1 1
The array contains: 1

The bolded part is what I cant get to work. I have tried this and it keeps telling me I have not identified the items when I have. I'm not even sure if I am doing this right, so if anyone can help me out I will greatly appreciate it, thanks.

Here is my code:



#include "stdafx.h"
#include <iostream>
using namespace std;


int main ()

{
      const int MAX = 10;  
	  int a[MAX] = {0}; 
      int i; 
      int j; 
      int k = 0; 
      int duplicate; 
      int value; 

      cout << "Please enter your 10 numbers:" << endl;

     
      for ( i = 0; i <= MAX - 1; i++ )

	  {

         duplicate = 0;

         cin >> value;

      
		 if ( value >= 0 && value <= 100 )

		 {
            for ( j = 0; j < k; j++ )

		    {

               
               if ( value == a[j] )

			   {
                  duplicate = 1;
				  
                  break;
               }

          }

           
            if ( !duplicate )

		    {
		    	 a[k++] = value;

            } 

		 } 

		
      } 

      cout << "The array contains:" << endl;

    
      for ( i = 0; a[i] && i < MAX != 0; i++ )

	  {

         cout << a[i] << " ";

      }

      cout << "\n";





void showValues( int[],int);


int main2();


{

const int ARRAY_SIZE=10;


int numbers[ARRAY_SIZE]={value};


showValues(numbers, ARRAY_SIZE);



}


void showValues( int nums[], int size);


{

	for (int index = 0; index < ARRAY_SIZE; index++)


		cout<< numbers[index] << " " << endl;


}


system("pause");


return 0; 


}

Your functions should be outside of main. Forward declarations are done in the global space before the entry point but after including headers. I'm afraid to ask what "main2()" is an attempt to do, C\C++ are compiled languages not scripts.
Topic archived. No new replies allowed.