The last Index of a string s is slndex sLength ssize slength


The last Index of a string s is: s.lndex() s.Length() s.size() s.length()-1 Write the output of the following segments of code: int c = 1; while (c

Solution

1)
s.length()-1 returns last index of string

2)
4x8x16x
Explanation:
loop runs until c <20
for each value of c, which is divisible by 4 but not 3,gets displayed followed by x.
From values 1-20, only nos that satisfy this are 4 8 16

3)
rwaiths
riths
rs

Explanation:
Until the length of string is greater than 3,all characters from 1-3 gets erased and is displayed

4)

3)
2 4 6 -2
Explanation:
loop runs from y>0.
In first iteration,as y<8, it gets incremented by 2 and hence 2 gets printed
In second and third,same holds true and 4 6 gets printed
In fourth iteration as y==6, it gets decremented by 10 and hence -4 .And as y<8,it gets incremented by 2 and -2 gets printed.


5)

20a9b16a7b12a
Explanation:
loop runs from 10 ,gets decremented ny 1 and runs till 5
for odd iterations,first conditon get satisfied and i *2 gets printed
for even iterations, second condition gets satisified and i followed by b gets printed.

 The last Index of a string s is: s.lndex() s.Length() s.size() s.length()-1 Write the output of the following segments of code: int c = 1; while (c Solution1)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site