Sk Coders
Sk Coders

Reputation: 21

Difference between int variable and int data

I am a beginner in C++.

What is difference between int variable and int data? Are variable type and data type the same?

Upvotes: 1

Views: 84

Answers (2)

I S
I S

Reputation: 456

Their relation like water glass and water. The variable is a water glass it can hold water. The data is water itself.

An int variable is an area in memory that can hold integer data.

int data is like 1,2,3... you can assign it to int variable.

Upvotes: 3

Yunnosch
Yunnosch

Reputation: 26753

The expressions "variable type" and "data type" are used interchangeably.
There is however a difference between "variable" and "data".

A non-compound (i.e. not array, struct, vector, list...) variable can hold one piece of data of a given type. That data can and usually will change during execution of a program. I.e. it can contain different data of the type, but not at the same time.

When mentioning "data", people usually refer to larger amounts, like all the data read from an input file. Often an input variable is involved which, one after another, will hold all parts of the input. Similar for output, a program can generate lots of output data, with little or even no input.

Upvotes: 2

Related Questions