problem in array

#include <iostream>

using namespace std;




void main()
{
const int size=20;
int i=1;
int num[size]={0};
int arrayElement;
int counter=0;
int z=0;
while(i<=10)
{
cout<<"enter number";
cin>>arrayElement;

if(i==0)
num[0]=arrayElement;

else{

for(int j=0;j<size;j++)
{
if(num[j]==arrayElement)
z=1;
}
if (z==0){

num[counter]=arrayElement;
counter++;
}


i++;
}}

for(int k=0;k<counter;k++)
cout<<num[k]<<endl;


}
Use code tags, please.

What problem?

Note, in your code you do:
1
2
3
4
5
6
7
8
9
10
11
12
  int i=1;
  while(i<=10)
    {
      if(i==0)
	{
	  num[0]=arrayElement;
	}
      else
	{
	  i++;
	}
    }

Do you spot anything peculiar in that?
Topic archived. No new replies allowed.