August 2000
CA208 : 'C' PROGRAMMING

QUESTION 3

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 3

(a) Declare a pointer to an array of characters, called MyChar, the length of which should not be decided until allocation time. [1 mark]

(b) Give the results of executing the following function calls, and explain your answer:
(i) printf("%d\n", strlen("Hello World\n")); [2 marks]
(ii) printf("%d\n", sizeof("Hello World\n")); [2 marks]

(c) Implement a function, called Convert, which takes a pointer to a string s, and converts all of the lower case characters in the string to upper case characters. All upper case characters should remain unchanged. Note that the ASCII values of A to Z is the range 65 to 90, and a to z is 97 to 122. [5 marks]

(d) Implement a function, called StrCaseCmp, such that it takes in two pointers to strings, s and t and compares the two strings, ignoring the case of the individual characters. The function should return an integer less than, equal to or greater than zero if s is found, respectively, to be less than, equal to or greater than t. [5 marks]