cin<<a;
Here, you're using the wrong operator. Think of the angle brackets as showing the flow of data. You want:
cin>>a;
Similarly with cout
:
cout<<t[i];
You are also indexing t
with a
, rather than with i
, in the first for
loop:
t[i]=rand();
//^ This is i, not a
Another problem is that you are using a compiler extension to create an array of run-time size. That is, with standard C++ you cannot use a
as the size of your array since it is not known at compile time.