Computer Science, asked by vidhidave4771, 1 year ago

Briefly describe the building blocks of a program.

Answers

Answered by PranavAt
3
The terminology and details for constructing a program vary by language, but tend to follow a few common principles. The following presentation is very informal. All of these items will be discussed in more detail later.

    Programs are created from a series of characters (letters, digits, punctuation, and other characters) from the source character set.

    Characters are grouped into tokens. Each token, which can be one or more characters, has a distinct meaning in the language. Comments and white space are generally not considered to be tokens. Depending on how a language defines tokens, they can include operators, literals, keywords (or reserved words), and identifiers.

C

    C has five classes of tokens: operators, separators, identifiers, reserved words, and constants.

    A token is distinguished by the fact that if you try to break it up into smaller elements that it will lose or change its meaning. To use a simple example, the characters 3.5 collectively have the clear meaning of three and a half, but individually mean three, period, and five. A token is indivisible.

    Literals are symbols used to indicate a specific value. Anytime you encounter a raw number, such as 2 or 573.9901, you are seeing an example of a numeric literal. There are other kinds of literals beyond just numbers.

    Operators are symbols (usually one or two characters) that indicate an operation (such as the plus sign [+] for addition).

    Separators are symbols that are used to separate portions of your source code. Some languages don’t use this concept. Some languages consider whitespace to be a separator, while other languages don’t (even if whitespace is used to separate tokens).

    Key words or reserved words are the commands (and related terminology) of a programming language (such as the ubiquitious IF command). Reserved words can not be used for any other purpose. Some languages (such as PL/I) allow key words to be reassigned to other purposes (which creates massive confusion and is a horribly bad programming practice). In most languages, there is no distinction between the terms keywords and reserved words.

    Identifiers are names. This includes the names of programs, modules, procedures, functions, variables, constants, etc. In some languages this may include reserved words or key words. Note that in the c programming language, constants are not considered an identifier.

    Tokens can be grouped together into statements. Some languages have subgroups of statements called expessions.

    In some languages (such as C) there is a special character (or characters) that terminates (or marks the end of) a statment. In some languages (such as Pascal) there is a special character (or characters) that seperates statements. This is a subtle but important difference. Some languages (such as FORTRAN) are line oriented, with one statement to a line (with a continuation character to allow for multiple line statements).

    Statements may (in most modern languages) be grouped into blocks of code.

    Most modern programming languages have a header and a body, although few call them by those exact names.

    Generally declarations go into the header and statements and blocks of code go into the body.
I think this help you....
Follow me


Similar questions