Docsity

C Exam Questions - Information Technology Support and Software Development, Exams of Software Development Methodologies

Toggle sidebar
bg1
Cork Institute of Technology
Higher Certificate in Computing in Information Technology Support – Award
(National Certificate in Computing in Information Technology Support – Award)
(NFQ – Level 6)
Summer 2005
Software Development
(Time: 2 ½ Hours)
Instructions: Examiner: Ms Gemma O’Callaghan
Answer questions 1 and any two others. Dr. D. Chambers
Question 1 is compulsory. Mr. E. A. Parlsow
Mr. P. O’Connor
Question 1: (50 marks)
(a) Assume the following declarations have been made:
int a,b;
double radius;
char ch;
Tell whether each of the following is a valid C statement. If it is not valid, explain why it is
not.
1. radius = 2.5; 2. 0 = b; 3. b = b + b; 4. b + b = b; 5.a = 1;
6. a = “1”; 7. a = b = 1; 8. ch = ‘65’; 9. ch = 65; 10. a++;
(5 marks)
(b) Irish Bank Ltd will approve a credit card application from a customer if the applicant’s
income is at least €25,000 or the value of his or her assets is at least €70,000; in addition, the
applicant’s total liabilities must be less than €20,000. Write a function cardApproval() that
receives three numbers representing income, assets, and liabilities, and returns an integer
value that corresponds to a true situation if the criteria for credit card approval are satisfied
and false otherwise.
(4 marks)
(c) Each year an insurance company sends out dividend cheques to its policyholders. The basic
dividend rate is a fixed percentage (4.5%) of the policyholder’s premium. If the policyholder
has made no claims, the dividend rate for that policy is increased by a bonus rate (0.5%).
Write a function that computes and returns the dividends for a particular policyholder give his
or her premium and number of claims.
(6 marks)
pf3
pf4

Partial preview of the text

Download C Exam Questions - Information Technology Support and Software Development and more Exams Software Development Methodologies in PDF only on Docsity!

Cork Institute of Technology

Higher Certificate in Computing in Information Technology Support – Award

(National Certificate in Computing in Information Technology Support – Award)

(NFQ – Level 6)

Summer 2005

Software Development

(Time: 2 ½ Hours)

Instructions: Examiner: Ms Gemma O’Callaghan Answer questions 1 and any two others. Dr. D. Chambers Question 1 is compulsory. Mr. E. A. Parlsow Mr. P. O’Connor

Question 1: (50 marks)

(a) Assume the following declarations have been made: int a,b; double radius; char ch; Tell whether each of the following is a valid C statement. If it is not valid, explain why it is not.

  1. radius = 2.5; 2. 0 = b; 3. b = b + b; 4. b + b = b; 5.a = 1;
  2. a = “1”; 7. a = b = 1; 8. ch = ‘65’; 9. ch = 65; 10. a++; (5 marks)

(b) Irish Bank Ltd will approve a credit card application from a customer if the applicant’s income is at least €25,000 or the value of his or her assets is at least €70,000; in addition, the applicant’s total liabilities must be less than €20,000. Write a function cardApproval() that receives three numbers representing income, assets, and liabilities, and returns an integer value that corresponds to a true situation if the criteria for credit card approval are satisfied and false otherwise. (4 marks)

(c) Each year an insurance company sends out dividend cheques to its policyholders. The basic dividend rate is a fixed percentage (4.5%) of the policyholder’s premium. If the policyholder has made no claims, the dividend rate for that policy is increased by a bonus rate (0.5%). Write a function that computes and returns the dividends for a particular policyholder give his or her premium and number of claims.

(d) Convert the following if-else statements into a switch statement:

if (yearCode == 1) printf(“Freshman”); else if (yearCode == 2) printf(“Sophomore”); else if (yearCode == 3) printf(“Junior”); else if (yearCode == 4) printf(“Senior”); else if (yearCode == 5) printf(“Graduate”); else printf(“You have entered an invalid year code”); (6 marks)

(e) Print the integers from 1 to 30 using a for loop. Print only 5 characters per line.

(4 marks)

(f) Write definitions and statements to construct the following arrays: An array whose indices are the integers from 0 through 999 and in which the value stored in each element is the same as the index. An array whose indices are the integers from 0 through 99 and in which the value stored in the elements are the indices in reverse order. (8 marks)

(g) Given a char pointer variable ptr_ch, are the following statements legal?

  1. *ptr_ch = ‘x’;
  2. ptr_ch = “This is a character string”;
  3. ptr_ch = ‘c’;
  4. *ptr_ch = “Another character string”; (4 marks) (h) In the following list, which statements are legal?
  5. Char str1[4] = “Exam”;
  6. Char str2[] = “Summer Exam”;
  7. Char str3[2] = “A”;
  8. Char str4[4] = “time”; (4 marks)

(i) Suppose that the following declarations have been made: int a[] = {12,14,15,18,25,11,36,42}; int *p = &a[1]; int *q = &a[5]; What is the value of the following?

  1. *p
  2. *(p + 4)
  3. *(q – 2)

Question 3: (25 marks) ABC Ltd is a shipping company that has 50 employees working for them at present. They are currently doing their end of year accounts and would like to have all of their employees salaries stored in a double array called Salaries. They are interested in doing some analysis on the salaries their employees are paid. They wish to find the lowest, largest and average salary paid to their employees this year. They also wish to calculate the total amount they paid out in salaries for this year.

(a) Write the C code to declare the array and to read in the salaries into the array as the user at the keyboard enters them. Please note that there is a stipulation that an employee’s salary cannot be over sixty thousand euro. You need to ensure that no value in the array Salaries holds a value greater than sixty thousand. (8 marks) (b) Write a C function that receives the array and the size of the array as parameters and calculates the lowest salary entered along with the highest salary entered. You should also display your results to the screen. (10 marks)

(c) Write a C function that receives the array and the size of the array as parameters and calculates the average salary received by all employees. You should also display your results to the screen. (7 marks)

Question 4: (25 marks) (a) Why would you use a data structure and name 4 common operations performed on data structures. (5 marks)

(b) Analyse the following algorithm and calculate it’s running time. Adding up all entries in an array of integers: Given an array of size n Set sum to 0 For every position from 1 to n Set sum = sum + the entry at the position Return sum (4 marks)

(c) Describe, in detail, the data structure known as the linked list. (6 marks)

(d) Sorting is an important operation performed on data structures. Describe the following sorting techniques in detail. Selection Sort Bubble Sort Insertion Sort (10 marks)