CPS 10 (Ramm) Spring 1995 February 1 Quiz #3 Name _______________________ Section _____ (Note: Getting your Name and Section right is worth one point.) A. Assume the following Pascal program is run. The user types the following string as input: PORTUGAL Show exactly what output the program produces. (Remember that for these purposes, upper and lower case characters are different.) program tm1; OUTPUT (lined up with writeln's) var -------------------------------- stra, strb, strc: string; i, lng: integer; begin readln(stra); strb := copy(stra, 4, 3); writeln(strb); strc := stra + ' -> ' + strb; writeln(strc); i := pos('T', stra); lng := length(stra); writeln(i, ' ', lng); strc := copy(stra, 1, i-1) + copy(stra, i+1, lng - i); writeln(strc); writeln(stra + stra); writeln('final'); readln; end. B. The following program reads in a string more than 2 characters in length. Complete the missing statement so that the program will print out the string with its last character moved to the front. (For example, if the user types ABCDEF, the program should write out FABCDE.) program changestr; var str, newstr: string; begin writeln('Enter a string 2 or more characters long'); readln(str); newstr := ______________________________________________________ writeln(newstr); {complete statement above} readln; end.