Multiple choice technology mainframe

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

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

SORT FIELDS sorts by name (positions 1-6, character, ascending). SUM FIELDS sums the numeric age (positions 7-8, packed decimal) for duplicate names. Arun: 20+50=70, Naveen: 40+10=50, Priya: 35+25=60. Sorted output with summed values: Arun 70, Naveen 50, Priya 60.

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.