Which of the following statements are correct in the context of programming…

2024

Which of the following statements are correct in the context of programming languages?

A. Algorithm solves a problem in a finite number of steps

B. Assembly language is a low level programming language

C. A code written in machine language is highly portable

D. Algorithms are implemented using programming languages

Choose the correct answer from the options given below:

Answer: B. A, B & D onlyConcept An algorithm is a finite, unambiguous sequence of well-defined steps that turns an input into the required output; finiteness — it must halt after a…

  1. A.

    A, B & C only

  2. B.

    A, B & D only

  3. C.

    B, C & D only

  4. D.

    A, C & D only

Attempted by 18 students.

Show answer & explanation

Correct answer: B

Concept

An algorithm is a finite, unambiguous sequence of well-defined steps that turns an input into the required output; finiteness — it must halt after a bounded number of steps — is part of the definition itself, not an optional quality. An algorithm is also language-independent: it is a plan, and it becomes something a machine can run only when it is written out in a programming language and translated into machine instructions.

Programming languages sit on a ladder of abstraction, and portability — the ability to run the same code on a machine of a different architecture — decreases as a language moves closer to the hardware.

Language level

What the programmer writes

Portability across machines

Machine language

Binary instruction codes for one instruction-set architecture

Lowest: the binary is tied to that processor family

Assembly language

Mnemonics mapped almost one-to-one onto those machine instructions

Very low: it must be rewritten for another architecture

High-level language

Statements written independently of any processor

High: the same source is recompiled or interpreted per machine

Application

Test each statement against those definitions.

  • A. Algorithm solves a problem in a finite number of steps — finiteness is a defining property of an algorithm; a procedure that never halts is not an algorithm. The statement agrees with the definition.

  • B. Assembly language is a low level programming language — assembly mnemonics correspond almost one-to-one to a particular processor’s machine instructions, and the programmer manages registers and memory addresses directly. That is exactly what "low level" means, so the statement agrees with the definition.

  • C. A code written in machine language is highly portable — a machine-language program is a binary encoding for one instruction-set architecture, so the same binary will not execute on a processor of a different family. Machine code is the least portable form of program, so this statement contradicts the definition of portability.

  • D. Algorithms are implemented using programming languages — an algorithm is a design; a computer executes it only after it has been coded in a programming language and translated into machine instructions. The statement agrees with the definition.

Cross-check

Three statements survive the test — A, B and D — and one fails, namely C, so the combination that must be chosen is the one holding A, B and D while dropping C: "A, B & D only".

A quick sanity check on C: portability is the very reason high-level languages exist. The same C or Java source can be recompiled for a different machine, whereas the machine code produced from it for one architecture will not run on another. If machine language were highly portable, compilers targeting different processors would be unnecessary.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…