# [Solved]COBOL Interview Ques: About PERFORM loops

Author Message
ayyappa_22523
Warnings : 2

New User

Joined: 02 Jun 2005
Posts: 36

 Posted: Mon Jun 13, 2005 9:45 am i had a loop is how to perform d . if a = 1 if b = 1 perform c end if. else if b=1 perform c. else perform d. i want to perform d. ans is 1. a= 1 b = 1 2. a=2 b=1 3. a = 2 b = 2 4.a =1 b = 2

Active User

Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

 Posted: Mon Jun 13, 2005 12:03 pm answer is 4.
ayyappa_22523
Warnings : 2

New User

Joined: 02 Jun 2005
Posts: 36

 Posted: Mon Jun 13, 2005 3:08 pm i hope u have to cheet it once because here i use endif. after first if. if a = 1 means . tha will perform c. a = 2 means it will come esle if part. and elseif belongs to first if . second if will be terminated by end if.
kanak

Moderator

Joined: 12 Mar 2005
Posts: 252
Location: India

 Posted: Mon Jun 13, 2005 7:36 pm i think it will give compilation error as there is period after end-if. hence next else will be wrong. same way after perform c. if code is somewhat llike only one period after perform D then i think answer will be 3. i.e. a=2 then it will come to next if part and then if b=2 then it will cme to else part and execute D. ayyappa_22523 can you please check the period, where it should be exactly.
ayyappa_22523
Warnings : 2

New User

Joined: 02 Jun 2005
Posts: 36

 Posted: Tue Jun 14, 2005 11:25 am i will give it clearly now if a= 1 then if b=1 then preform c end- if else if b =1 then perform c else perfom d. then u have to say.
subbprem

New User

Joined: 20 Apr 2005
Posts: 9
Location: Chennai

 Posted: Tue Jun 14, 2005 12:42 pm answer is 3. _________________ regds, Prema.
kanak

Moderator

Joined: 12 Mar 2005
Posts: 252
Location: India

 Posted: Tue Jun 14, 2005 2:04 pm then answer in 3. When a not equla to 1 and b is not equal to 1.
ayyappa_22523
Warnings : 2

New User

Joined: 02 Jun 2005
Posts: 36

 Posted: Wed Jun 15, 2005 7:31 am thank u kk and all for slove the prob
flyingSnail

New User

Joined: 15 Jun 2005
Posts: 5
Location: China

 Posted: Thu Jun 16, 2005 12:25 pm I think you should use code-indent method to code your codes, that will make it easier to solve this question.

Active User

Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

 Posted: Fri Jun 17, 2005 5:50 pm what is code-indent method?how will it be usefull here?
kanak

Moderator

Joined: 12 Mar 2005
Posts: 252
Location: India

Posted: Fri Jun 17, 2005 6:07 pm

code indent methos is nothing but all the if,else and end-if should come in the same line so that you better way to describe the code. For example:
 Code: if a= 1 then    if b=1 then             preform c    end- if else    if b =1 then       perform c    else            perfom d.

I hope this is what flyingSnailmeant. If wrong then please correct me.

Active User

Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

 Posted: Mon Jun 20, 2005 9:20 am ohhh..I got it.thanks.
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Changeman - how can we know the curr... Compuware & Other Tools 2 Dynamically pass table name to a sele... DB2 2 REXX code to expand copybook in a cob... CLIST & REXX 2 Use of Perform Thru Exit COBOL Programming 6 Looking for COBOL, C/C++ developer Mainframe Jobs 0
Search our Forums:

 IBMMainframes.com is not an official and/or affiliated with IBM® in anyway Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us