View previous topic :: View next topic
|
Author |
Message |
ayyappa_22523 Warnings : 2 New User
Joined: 02 Jun 2005 Posts: 36 Location: Hyderabad
|
|
|
|
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 |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
answer is 4. |
|
Back to top |
|
|
ayyappa_22523 Warnings : 2 New User
Joined: 02 Jun 2005 Posts: 36 Location: Hyderabad
|
|
|
|
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 |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
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 |
|
|
ayyappa_22523 Warnings : 2 New User
Joined: 02 Jun 2005 Posts: 36 Location: Hyderabad
|
|
|
|
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 |
|
|
subbprem
New User
Joined: 20 Apr 2005 Posts: 9 Location: Chennai
|
|
|
|
answer is 3.
_________________
regds,
Prema. |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
then answer in 3. When a not equla to 1 and b is not equal to 1. |
|
Back to top |
|
|
ayyappa_22523 Warnings : 2 New User
Joined: 02 Jun 2005 Posts: 36 Location: Hyderabad
|
|
|
|
thank u kk and all for slove the prob |
|
Back to top |
|
|
flyingSnail
New User
Joined: 15 Jun 2005 Posts: 5 Location: China
|
|
|
|
I think you should use code-indent method to code your codes, that will make it easier to solve this question. |
|
Back to top |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
what is code-indent method?how will it be usefull here? |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
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 |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
ohhh..I got it.thanks. |
|
Back to top |
|
|
|