Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Output of a cobol pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
kespra
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 24
Location: bangalore

PostPosted: Thu Sep 04, 2008 7:21 pm    Post subject: Output of a cobol pgm
Reply with quote

If 1>0
next sentence
endif.
Display"Line1".
Display"Line2"..
Display"Line3"

What is the output of this??
Back to top
View user's profile Send private message
References
Anuj D.

Global Moderator


Joined: 22 Apr 2006
Posts: 2240
Location: Mumbai, India

PostPosted: Thu Sep 04, 2008 8:02 pm    Post subject:
Reply with quote

Hi,

As posted - the code will not compile. Did you try it, what was the result ?
Back to top
View user's profile Send private message
kespra
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 24
Location: bangalore

PostPosted: Thu Sep 04, 2008 8:12 pm    Post subject:
Reply with quote

No this was asked in an interview and may I know the reason why it will not compile.
Back to top
View user's profile Send private message
Anuj D.

Global Moderator


Joined: 22 Apr 2006
Posts: 2240
Location: Mumbai, India

PostPosted: Thu Sep 04, 2008 8:29 pm    Post subject:
Reply with quote

Hi,

Well, when I tried the given code, at my shop, compilation was fialed with the following description -

The indicated statement contains a comparison between the two indicated literals. The indicated comparison was ignored.

Respecify the indicated statement so that the indicated comparison is removed. Since the outcome of comparing two literals (i.e., two known, unvarying values) is always predictable, respecify the indicated statement without the indicated comparison but so that it will function as if the comparison had taken place and given the predictable result.
Back to top
View user's profile Send private message
kespra
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 24
Location: bangalore

PostPosted: Thu Sep 04, 2008 8:34 pm    Post subject:
Reply with quote

Then how to debug and what changes has to be made in the pgm.
Back to top
View user's profile Send private message
Moved: Thu Sep 04, 2008 8:36 pm by superk From Mainframe COBOL to Interview Questions
Robert Sample

Senior Member


Joined: 06 Jun 2008
Posts: 961
Location: Atlanta, GA

PostPosted: Thu Sep 04, 2008 8:36 pm    Post subject:
Reply with quote

Debugging implies a working program. This program won't compile so it doesn't work by default. No debugging is required.

Since the error message says two literals cannot be compared, and the IF statement is syntactically null anyway, delete the entire IF statement and proceed.
Back to top
View user's profile Send private message
Anuj D.

Global Moderator


Joined: 22 Apr 2006
Posts: 2240
Location: Mumbai, India

PostPosted: Thu Sep 04, 2008 8:41 pm    Post subject:
Reply with quote

Hi,

You can try something like -
Code:
 WORKING-STORAGE SECTION.           
  01 FIRST-VAR  PIC 9(01) VALUE 1. 
  01 SECND-VAR  PIC 9(01) VALUE 0. 
*                                   
 PROCEDURE DIVISION.               
*                                   
 MAIN-LOGIC.                       
*                                   
     IF FIRST-VAR > SECND-VAR       
         NEXT SENTENCE                 
     END-IF.                       
         DISPLAY"LINE1".               
         DISPLAY"LINE2"..               
         DISPLAY"LINE3"                 
     STOP RUN.                     
 MAIN-LOGIC-EXIT.                   
        EXIT.                       


Output would be -
Code:
LINE1
LINE2
LINE3
Back to top
View user's profile Send private message
arcvns

Senior Member


Joined: 17 Oct 2006
Posts: 802
Location: Chennai, India

PostPosted: Thu Sep 04, 2008 8:42 pm    Post subject:
Reply with quote

Since the result of the comparison is already known, modify the statement to remove the comparison to function as if the comparison has taken place and given the result.

In short if the statement if TRUE, remove the IF condition alone and if the statement is FALSE, remove the IF condition and its content.

Thanks,
Arun
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1