15.01.2015 Views

CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional

CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional

CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

18. In the fragment below, what is the minimum size of result required for<br />

successful and valid concatenation of "double" and "trouble"<br />

strcpy(result, "double");<br />

strcat(result, "trouble");<br />

(a) 11<br />

(b) 12<br />

(c) 14<br />

(d) 15<br />

19. Which of the following correctly copies the contents of string2 into<br />

string1 Assume that string2 is equal to "Good" and string1 is<br />

equal to "Morning"<br />

(a) strcat( string1, string2 );<br />

(b) strcpy( string2, string1, 7 );<br />

(c) strncpy( string1, string2, 6 );<br />

(d) strcpy( string1, string2 );<br />

20. Which statement is FALSE<br />

(a) Function strcpy copies its first argument into its second argument.<br />

(b) Function strncpy does not necessarily copy the terminating null<br />

character of its second argument.<br />

(c) A common error is not appending a terminating null character to the<br />

first argument of a strncpy when the third argument is less than or<br />

equal to the length of the string in the second argument.<br />

(d) The first character of the second argument of strcat replaces the<br />

null character that terminates the string in the first argument.<br />

Semester 2 2006/2007<br />

Page 7 of 11<br />

Principles of Programming

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!