# cols {#cols}

## Syntax {#syntax}

`cols(X)`

## Arguments {#arguments}

**X** is a vector/matrix/table.

## Details {#details}

Return the total number of columns in *X*. Please check related function: [rows](../r/rows.md).

## Examples {#examples}

```
x=1..6$2:3;
x;
```

|\#0|\#1|\#2|
|---|---|---|
|1|3|5|
|2|4|6|

```
cols x;
// output: 3

a=table(1..3 as x,`IBM`C`AAPL as y);
a;
```

|x|y|
|---|---|
|1|IBM|
|2|C|
|3|AAPL|

```
cols a;
// output: 2

y=1 2 3;
cols(y);
// output: 1  // a vector can be viewed as an n*1 matrix
```

