Sei sulla pagina 1di 6

THE UNIVERSITY OF TRINIDAD & TOBAGO

FINAL ASSESSMENT/EXAMINATIONS DECEMBER 2012

Course Code and Title:

[PRGA1001 Programming I]

Programme:

[BASc Common Year I]

Date and Time:

[December 13, 2012.

Duration:

[3 Hours]

9:00 am -12:00 noon]

PLEASE READ ALL INSTRUCTIONS CAREFULLY BEFORE YOU BEGIN THIS


EXAMINATION

Instructions to Candidates
[Please amend as required, and ensure that instructions are accurate and clear]
1. This paper has _6_ pages and _8_questions.
2. You are required to answer all questions
The question paper is to be returned with the Answer script.
Key Examination Protocol
1. Students please note that academic dishonesty (or cheating) includes but is not limited to
plagiarism, collusion, falsification, replication, taking unauthorised notes or devices into an
examination, obtaining an unauthorised copy of the examination paper, communicating or
trying to communicate with another candidate during the examination, and being a party to
impersonation in relation to an examination.
2. The above mentioned and any other actions which compromise the integrity of the academic
evaluation process will be fully investigated and addressed in accordance with UTTs
academic regulations.
3. Please be reminded that speaking without the Invigilators permission is NOT allowed.

The University of Trinidad and Tobago


December 2012 Final Examinations
(PRGA1001)

Page 1

Question

mark

/ 7

10

10

15

10

----------------------------------------------------------------TOTAL

The University of Trinidad and Tobago


December 2012 Final Examinations
(PRGA1001)

75

Page 2

QUESTION 1 (7 marks)
Write a program which reads in a number from the user which represents a temperature
in degrees Fahrenheit. It then calculates and outputs the equivalent temperature in
degrees Celsius using the formula:
C = (F - 32) x 5/9

QUESTION 2 (6 marks)
What would be the output from the following program:
#include <stdio.h>
void main()
{
int x = -2, a = 3;
while (x <= 16)
{
a += 5;
x += 3;
}
printf ("a = %d \n", a);
}

The University of Trinidad and Tobago


December 2012 Final Examinations
(PRGA1001)

Page 3

QUESTION 3 (10 marks)


The Taylor expansion for determining the sine of an angle is given as follows:

x1
x3
x5
x7
x9
Sin ( x)

1!
3!
5!
7!
9!
Your job is to write a C program to determine the sine of an angle. The input consists of
the value of the angle in degrees and the output consists of the sine of the angle. Apply
the Taylor expansion to 20 terms in order to determine the sine of the angle.

QUESTION 4 (10 MARKS)


This question requires you to develop a C program to determine the area bounded by
the graph of
f(x) = 3x2 + 11x - 6
and the x-axis.
You must first determine the points at which the graph intersects the x-axis and the yaxes. Then produce a sketch of the graph showing the points of intersection with both
the x and y axes and shade the relevant area. Determine and show the exact value of
the required area using integration.
Write a program which uses numerical integration to approximate the area bounded by
the graph and the x-axis. As discussed in our lectures, this method requires the use of
trapezoids to approximate the area.

The University of Trinidad and Tobago


December 2012 Final Examinations
(PRGA1001)

Page 4

QUESTION 5 (15 marks)


This question deals with processing the monthly transactions of the clients of a bank.
For each client, your program should read in the account number of the client (integer),
followed by the starting balance. For each transaction for this client, your program
should read in the type of transaction (W or D), followed by the amount of money
involved in the transaction. If the transaction is a withdrawal (W), then the amount
should be subtracted from the current balance and a new current balance should be
obtained. Similarly, if the transaction is a deposit (D), then the amount should be added
to the running balance.
After processing one transaction for a client, your program should prompt the user for
more transactions, for example, the prompt might be:
Any more transactions Y/N?
If the response is Y, then your program should repeat the process of asking for the type
of transaction and amount, and continue processing as stated above. If the response is
N, then your program should output the total amount deposited, the total amount
withdrawn, and the final balance for the client along with his account number. After this
output, your program should prompt for more clients to be processed. If there are more
clients, then proceed to request the account number of the client along with his starting
balance, and repeat the entire process regarding transactions, as stated above.
Your program should validate the transaction type (W or D), as well as the
response to each question (Y or N). Your program should not accept invalid responses.
Even though we have been using uppercase for the type of transaction as well as
the response, your program must be able to handle inputs in either lowercase or
uppercase from the user. We will be looking for the most efficient code to handle this
requirement.

The University of Trinidad and Tobago


December 2012 Final Examinations
(PRGA1001)

Page 5

QUESTION 6 (10 marks)

Indicate all the steps that you would use in SciLAB in order to determine and display the
following integral
(

using the function trapezoidal rule as follows:

( )

[ ( )

( )]

[ ( )

( )]

where h = b a

QUESTION 7 (9 MARKS)
Write a SciLAB script to multiply the following polynomials:
y = 3x3 + 7x2 + 18
y = 8x2 - 3

QUESTION 8 (8 MARKS)
This question deals with the development of a SciLab script to evaluate a polynomial at
a specific point. The polynomial to be evaluated is:
y = 4x4 - 3x3 + 2x - 8
Your script must allow the use to enter the value of x at which the polynomial is to be
evaluated, and must display the required value.

END OF PAPER
The University of Trinidad and Tobago
December 2012 Final Examinations
(PRGA1001)

Page 6

Potrebbero piacerti anche