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

[Solved]COBOL Interview Ques: About PERFORM loops


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ayyappa_22523
Warnings : 2

New User


Joined: 02 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Mon Jun 13, 2005 9:45 am
Reply with quote

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
Back to top
View user's profile Send private message
radhakrishnan82

Active User


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

PostPosted: Mon Jun 13, 2005 12:03 pm
Reply with quote

answer is 4.
Back to top
View user's profile Send private message
ayyappa_22523
Warnings : 2

New User


Joined: 02 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Mon Jun 13, 2005 3:08 pm
Reply with quote

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.
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Mon Jun 13, 2005 7:36 pm
Reply with quote

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.
Back to top
View user's profile Send private message
ayyappa_22523
Warnings : 2

New User


Joined: 02 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Tue Jun 14, 2005 11:25 am
Reply with quote

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.
Back to top
View user's profile Send private message
subbprem

New User


Joined: 20 Apr 2005
Posts: 9
Location: Chennai

PostPosted: Tue Jun 14, 2005 12:42 pm
Reply with quote

answer is 3.
_________________
regds,
Prema.
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Tue Jun 14, 2005 2:04 pm
Reply with quote

then answer in 3. When a not equla to 1 and b is not equal to 1.
Back to top
View user's profile Send private message
ayyappa_22523
Warnings : 2

New User


Joined: 02 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Wed Jun 15, 2005 7:31 am
Reply with quote

thank u kk and all for slove the prob
Back to top
View user's profile Send private message
flyingSnail

New User


Joined: 15 Jun 2005
Posts: 5
Location: China

PostPosted: Thu Jun 16, 2005 12:25 pm
Reply with quote

I think you should use code-indent method to code your codes, that will make it easier to solve this question.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


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

PostPosted: Fri Jun 17, 2005 5:50 pm
Reply with quote

what is code-indent method?how will it be usefull here?
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Fri Jun 17, 2005 6:07 pm
Reply with quote

hai radhakrishnan v ,
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.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


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

PostPosted: Mon Jun 20, 2005 9:20 am
Reply with quote

ohhh..I got it.thanks.
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 Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts COBOL program logic for comparisipn o... COBOL Programming 2
No new posts COBOL - create and write to output fi... COBOL Programming 0
No new posts COBOL to JSON COBOL Programming 1
Search our Forums:

Back to Top