Computer Science, asked by RiyaWani, 1 year ago

detect the output
i =1
while ( i <=1)
{
i ++
SOP (1)
}
SOP ( i )

Answers

Answered by nitish8089
1
output
12 if SOP(System.out.print)
otherwise if SOP(System.out.println)
1
2
____________________
initial value of i=1.
while(i<=1)
it check the condition if i is less than or equal to 1 than the loop run otherwise not.
so for first check pass out(enter to loop due i=1) to.
now
i++ means i=i+1 so i=2.
and sop (system.out.print)
SOP(1) will print 1 but no line change.
and after coming out loop i=2 so while loop not run now.
SOP(i) print 2
so it's output become.
12
Attachments:

RiyaWani: sorry how did u got this ans
RiyaWani: thank you
nitish8089: ok i am explain on answer
RiyaWani: thank u
RiyaWani: plz explain
RiyaWani: how 12 its System. out. print
nitish8089: it's not twelve(12) it's one(1)and two(2)
nitish8089: it's your code
RiyaWani: thank you very much
nitish8089: welcome second
Similar questions