View previous topic :: View next topic
|
Author |
Message |
kespra Currently Banned New User
Joined: 03 Jun 2008 Posts: 24 Location: bangalore
|
|
|
|
If 1>0
next sentence
endif.
Display"Line1".
Display"Line2"..
Display"Line3"
What is the output of this?? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
As posted - the code will not compile. Did you try it, what was the result ? |
|
Back to top |
|
|
kespra Currently Banned New User
Joined: 03 Jun 2008 Posts: 24 Location: bangalore
|
|
|
|
No this was asked in an interview and may I know the reason why it will not compile. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
kespra Currently Banned New User
Joined: 03 Jun 2008 Posts: 24 Location: bangalore
|
|
|
|
Then how to debug and what changes has to be made in the pgm. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 -
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
|