In the i/p file A contains the records in the following sequence: Arun 20 Naveen40 Priya 35 Naveen10 Priya 25 Arun 50 If the following SORT query runs on file A, how would the o/p file B look like: SORT FIELDS = (1,6,CH,A) SUM FILEDS = (7,2,PD)

  1. Arun 50 Arun 20 Naveen10 Naveen40 Priya 25 Priya 35

  2. Priya 60 Naveen50 Arun 70

  3. Arun 70 Naveen50 Priya 60

  4. Naveen50 Priya 60 Arun 70


Correct Option: C

AI Explanation

To answer this question, we need to understand the SORT statement in COBOL.

The SORT statement is used to sort records in a file based on specified sort fields. In this case, the SORT statement is:

SORT FIELDS = (1,6,CH,A)
SUM FIELDS = (7,2,PD)

The SORT FIELDS clause specifies the fields to be used for sorting. In this case, it is sorting based on the first 6 characters in ascending order (A). The SUM FIELDS clause specifies the field to be summed, starting from position 7, for a length of 2, and the data type is packed decimal (PD).

Now let's go through each option to understand which one matches the output file B:

Option A) Arun 50 Arun 20 Naveen10 Naveen40 Priya 25 Priya 35 - This option is incorrect because it does not match the sorting and summing criteria specified in the SORT statement.

Option B) Priya 60 Naveen50 Arun 70 - This option is incorrect because it does not match the sorting and summing criteria specified in the SORT statement.

Option C) Arun 70 Naveen50 Priya 60 - This option is correct because it matches the sorting and summing criteria specified in the SORT statement. The records are sorted in ascending order based on the first 6 characters, and the sum of the fields starting from position 7 is calculated.

Option D) Naveen50 Priya 60 Arun 70 - This option is incorrect because it does not match the sorting and summing criteria specified in the SORT statement.

Therefore, the correct answer is option C. The output file B would look like: Arun 70 Naveen50 Priya 60.

Find more quizzes: