Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Computer Programming/Variables

From Wikibooks, open books for an open world
<Computer Programming
This computer programming article is available inpseudocode andAda.

Variables arereferences that stand in for avalue that is contained at a certain memory address.

Variables are said to have a value andmay have adata type. If a variable has a type, then only values of this type may be assigned to it. Variables do not always have a type.

A value can have many values of many different types: integers (7), ratios (1/2), (approximations of) reals (10.234), complex numbers (4+2i), characters ('a'), strings ("hello"), and much more.

Different languages use different names for their types and may not include any of the above.

Assignment statements

[edit source]

Anassignment statement is used to set a variable to a new value.


An assignment statements in wikibook pseudocode is written asletvariable:=value.

let X := 10

The example set the variableX to the integer value of10. The assignment statement overwrites the contents of the variable and the previous value is lost.

In some languages, before a variable can be used, it will have to be declared, where the declaration specifies the type.


But this is not needed in wikibook pseudocode.

Uses

[edit source]

Variables store everything in your program. The purpose of any useful program is to modify variables.

Retrieved from "https://en.wikibooks.org/w/index.php?title=Computer_Programming/Variables&oldid=3243207"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp