IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Output of a cobol pgm


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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

Superior Member


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

PostPosted: Thu Sep 04, 2008 8:02 pm
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
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

Superior Member


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

PostPosted: Thu Sep 04, 2008 8:29 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Sep 04, 2008 8:36 pm
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

Superior Member


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

PostPosted: Thu Sep 04, 2008 8:41 pm
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: 2481
Location: @my desk

PostPosted: Thu Sep 04, 2008 8:42 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top