Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ 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 -> Mainframe Interview Questions
View previous topic :: :: View next topic  
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

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
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 Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
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
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7930
Location: Bellevue, IA

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 Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
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
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2177
Location: @my desk

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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 6 Fri Jan 13, 2017 5:02 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us