Computer Test Answers with Explanations 1)Answer:D ---> copy(s,i,length(s)-i+1) Explanation: If we want to extract a sub-string , e.g. 'ice' from the word 'nice'(i is the i-th position), then size of 'ice'= length(nice)-i+1=4-i+1=4-2+1=3--->the size of the sub-string 'ice'.So D is the answer. 2)Only(2) is True. For (1), ABC =ABC but the second string contains a space, so they are not equal to each other.--->false For(2), A has an ASCII code of 65, and a has an ASCII aode of 97, so ABCTrue For(3), 3 has an ASCII code of 51 and 1 has an ASCII code of 49,so 32<123 is false. 3)1234789 As a and b are strings, not integers, they can not be added mathematically.Instead two strings can be added by putting next to each other.So 1234 + 789 =1234789 4)15 When i=1, a=123+45=12345,b=0+5+1=6 When i=2, a=12345+45=1234545, b=6+7+2=15 So the output ans of b is 15 5)65 A=ROMRAMROM As B =copy(a,5,5), B=AMROM B[1]=A So ord(A) =65 *6)PQRST when i=5, a[i]=chr(ord(E)+15)=T, so a[5]=T when i=4, a[i]=chr(ord(D)+15)=S so a[4]=S when i=3 a[i]=chr(ord(C)+15)=R so a[3]=R when i=2, a[i]=chr(ord(B)+15)=Q, so a[2]=Q when i=1 a[i]=chr(ord(A)+15)=P,so a[1]=P so write(a) will output a[1] to a[5] accordingly, so the output is PQRST **7)EUMCCOMP k=8 when i=1, a=COMPUTER[2*1-1]+COMPUTER=CCOMPUTER when i=2, a=CCOMPUTER[2*2-1]+CCOMPUTER=OCCOMPUTER when i=3, a=OCCOMPUTER[2*3-1]+OCCOMPUTER=MOCCOMPUTER when i=4 a=TOCCOMPUTER[2*4-1]+MOCCOMPUTER=POCCOMPUTER when i=5 a=POCCOMPUTER[2*5-1]+POCCOMPUTER=TPOCCOMPUTER when i=6 a=TPOCCOMPUTER[2*6-1]+TPOCCOMPUTER=ETPOCCOMPUTER when i=7 a=ETPOCCOMPUTER[2*7-1]+ETPOCCOMPUTER=RETPOCCOMPUTER when i=8 a=RETPOCCOMPUTER[2*8-1]+RETPOCCOMPUTER= 8)6 when k=1 copy(x,1,1)>copy(y,9-1,1)=C>E-->False when k=2 copy(x,2,1)>copy(y,9-2,1)=O>G-->True so s=0+1=1 when k=3 copy(x,3,1)>copy(y,9-3,1)=M>A-->True so s=1+1=2 when k=4 copy(x,4,1)>copy(y,9-4,1)=P>U-->true so s=2+1=3 when k=5 copy(x,5,1)>copy(y,9-5,1)=U>G-->True so s=3+1=4 when k=6 copy(x,6,1)>copy(y,9-6,1)=T>N-->True so s=4+1=5 when k=7 copy(x,7,1)>copy(y,9-7,1)=E>A-->True so s=5+1=6 when k=8 copy(x,8,1)>copy(y,9-8,1)=R>L-->False so the program will stop and the output value of s is 6 9)5 times b=0, when b<=8 then b=0+2=2 b=2, then b=2+2=4 b=4, then b=4+2=6 b=6 then b=6+2=8 b=8 then b=8+2=10 this program will stop after b reaching 10, so the program will be run for 5 times. 10)All are correct [the numbers in brackets are the ASCII codes] 1) 0>-3-->T or -5<-7-->F (T) 2)k(107)>K(75)-->T and a(97)>9-->T (T) 3)A(65)>8 (T)