Question:

Which of the following is invalid statement in FORTRAN

Show Hint

Fortran compilers ignore spaces in fixed-form source code.
As a result, statements like ‘DO 10 I = 1, 5‘ (a loop) can be written as ‘DO10I=1,5‘, and variable assignments like ‘DO 10001 = 1, 5‘ are syntactically valid assignments to the variable ‘DO10001‘.
  • Continue
  • Dimension X (30,20)
  • DO 10001 = 1,5
  • P + Q +
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understanding the Concept:
A programming language has strict syntax rules that define how statements must be structured.
Any statement that violates these grammatical rules cannot be parsed by the compiler, resulting in a syntax error.

Step 2: Detailed Explanation:

Let us evaluate the validity of each statement in Fortran:
- (A) Continue: The ‘CONTINUE‘ statement is a valid control statement in Fortran.
It is primarily used as a placeholder, often serving as the terminal statement of a ‘DO‘ loop. Thus, it is valid.
- (B) Dimension X (30,20): The ‘DIMENSION‘ statement is used to declare the size and shape of arrays. ‘Dimension X (30,20)‘ correctly declares ‘X‘ as a two-dimensional array with 30 rows and 20 columns. Thus, it is valid.
- (C) DO 10001 = 1,5: In fixed-format Fortran, spaces are ignored.
The compiler reads this statement as ‘DO10001 = 1,5‘.
This is interpreted as a valid variable assignment where the value $1$ is assigned to a real or integer variable named ‘DO10001‘ (representing an implicit loop or assignment depending on context). Thus, it does not cause a syntax failure in older Fortran standards.
- (D) P + Q +: This statement contains a trailing addition operator (‘+‘) with no following operand.
Since there is no variable or value to complete the operation, this expression is incomplete and invalid in any programming language, including Fortran.

Step 3: Final Answer:

The statement ‘P + Q +‘ is invalid in FORTRAN.
Was this answer helpful?
0
0