COBOL declaration and value of variable.

All sort of Mainframes Interview Questions.
Post Reply
HajiAmida
Registered Member
Posts: 10
Joined: Mon Dec 15, 2014 9:57 pm

COBOL declaration and value of variable.

Post by HajiAmida »

Hello,

Suppose i am declaring

Code: Select all

05 temp-a.
     10 temp-b pic x(1)
      10 temp-c pic x(1)

If I give if temp-a = '1' , means it is equivalent to if temp-b = 1 right? Anyone please confirm.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: COBOL declaration and value of variable.

Post by Robert Sample »

Actually, you are not quite correct. COBOL compares equal sizes of variables, so saying

Code: Select all

IF TEMP-A = '1'
is really comparing TEMP-A to '1 ' -- COBOL will add the blank after the one so the comparison values are the same size. So depending upon the value of temp-c, the IF TEMP-A = '1' statement you posted may or not work the same as IF TEMP-B = '1'.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”