Computer Science, asked by chobajanatun, 5 months ago

Define an assignment statement. ​

Answers

Answered by TheSarcasticSmile
48

Answer:

In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assignment statement (or expression) is a fundamental construct.

Explanation:

Hope it helps you

Answered by manas1913
1

Explanation:

An assignment statement gives a value to a variable. For example,

x = 5;

gives x the value 5.

The value of a variable may be changed. For example, if x has the value 5, then the assignment statement

x = x + 1;

will give x the value 6.

The general syntax of an assignment statement is

variable = expression;

where:

the variable must be declared;

the variable may be a simple name, or an indexed location in an array, or a field (instance variable) of an object, or a static field of a class; and

the expression must result in a value that is compatible with the type of the variable. In other words, it must be possible to cast the expression to the type of the variable.

Examples:

int i = 0;

price[itemNumber] = 0.80 * price[itemNumber];

myDog.name = "Fido";

INTERMEDIATE

An assignment "statement" is not really a statement (although it is typically used that way), but is an expression. The value of the expression is the value that is assigned to the variable. For example, the expression

i = j = k = 0;

sets all of i, j, and k to zero.

Similar questions