查看: 1071|回复: 12
|
拜托各位帮忙解决这张PAPER!!!TQ!
[复制链接]
|
|

楼主 |
发表于 6-4-2007 09:08 PM
|
显示全部楼层
题目1
Question 1 (Compulsory)
(A) State the storage-class modifier that allows a variable to be created in one file and used in another file. [1 mark]
(B) State the type modifier that allow a variable to store only positive values. [1 mark]
(C) Define a union called TransportType that has the following elements:
- PrivateCar : Character
- Bus: Character
- Train: Character
- Taxi: Character
- Bicycle: Character [2 marks]
(D) Declare a structure called EmpRec consisting of the following elements:
- EmpNum: 5 characters
- Name: 30 characters
- Transport: of Transport above [2 marks]
(E) State the output of the following statements:
- Printf(“%d”, 32|16); [1 marks]
- Printf(“%d”, 32 && 16); [1 marks]
- Printf(“%d”, 32>>16); [1 marks]
- Printf(“%d”, ~(32)); [1 marks]
- Printf(“%d”, ((32%4)-4)); [1 marks]
(F) Given the following declaration:
Float *unknown_var;
Explain what kind of value unknown_var store and what is the purpose of this value [2 marks]
(G) (i) Given the following function:
Int MullBy5 (int num)
{
Return num*5;
}
Is the above function passing by Value or Passing by Reference? [1 mark]
(ii) Write a procedure that has same effect as the above function, except that on exit, instead of returning the value, the result is passed back as the functions parameter. [2 marks]
(iii) Give the name for the type of parameter used in the above procedure. [1 mark]
(H) Is there a data type called string in C? Describe briefly how a string can be created in C. [2 marks]
(I) Write a function EncryptStr that take in a string parameters str, a integer parameter pos. The function EncryptStr changes all characters in str to the next pos characters. For Example, Encrypt (‘Hello’, 2) returns ‘jgnnq’
(J) (i) Write a recursive function MulMinMax that take in 3 value integer parameters min, max, and nextnum and return the product from min to max increasing min by nextnum up to and including max. For Example, MulMinMax(2, 10, 3) returns 80 (2x5x8).
The function header is given as
intMulMinMax (int min, int max, int nextnum)
(ii) Rewrite your solution to the above question, such that the parameters are passed in by reference, and the solution, which should be calculated iteractively, passed back as the first parameter. [3 marks] |
|
|
|
|
|
|
|

楼主 |
发表于 6-4-2007 09:10 PM
|
显示全部楼层
题目2
(Question 2)
(A) Explain the difference between pass by value and pass by reference. [1 mark]
(B) Explain the difference between iteration and recursion [1 mark]
(C) Give an example where it may be preferable to choose either an iterative or recursive solution to a problem. Justify your answer. [2 marks]
(D) (i) What is wrong with the following function?
Int somethingwrong (int n)
{
If (n == 1)
return 1;
return n * somethingwrong(n) [1 mark]
}
(ii) How do we solve the above problem? [1 mark]
(E) Write a procedure, called SumDiff, which takes in two references to floating point integers, a and b. On exit, a should refer to the difference between the two initial parameters, and b should refer to the sum of the two parameters. [4 marks]
(F) Write procedure, called FibArray, which takes in a reference to an integer array, and an integer specifying the length of the array. Assuming the first element of the array is set to 0, and the second to 1, each subsequent element of the array should be set to the sum of the previous two elements. For example, the third element of the array would be (0+1)=1. You should assume that the array contains at least three elements, and you should not changes the first two. [5 marks] |
|
|
|
|
|
|
|

楼主 |
发表于 6-4-2007 09:11 PM
|
显示全部楼层
题目3
(Question 3)
(A) BookWorm is a bookshop. Its owner Steve News asks you to develop an application to track his books.
BookWorm labls each of its books with an internal code. Create a structure called BWCodeType that stores the following information:
Category : a 2-character category type (like SF-Science Fiction, HR- Horros, etc)
ID: a10-digit number (you are not to store it as 10-character string) [2 marks]
(B) What is the benefit of defining data interm of structures? [1 marks]
(C)Create a structure called BookRec that stroes the following information:
- Title : can store up to a maximum of 100 characters
- Author : can store up to a maximum of 100 characters
- ISBN : 10-digit number (you are not to store as characters)
- Publisher : can store up to a maximum of 50 characters
- Price : floating point number
- Code : of BWCodeType above [4 marks]
(D) Declare an array called BWArray that can store up to 10000 BookRec records [1 mark]
(E) What is the problem of a program that manipulate (create, update or delete)records in an array only. [1 mark]
(F) What is the solution for the above problem? [1 mark]
(G) Write a function called FindBookUsingISBN that take in BWArray array, an integer parameter NumOfBooks which holds the number of books information n the shop and ISBNinput (the ISBN number needed to find the book). The function should display the title, Author, Publisher, Price and Code of the book. [5 marks] |
|
|
|
|
|
|
|

楼主 |
发表于 8-4-2007 03:08 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 8-4-2007 05:50 PM
|
显示全部楼层
你在期待这边的人帮你做功课吗?  |
|
|
|
|
|
|
|

楼主 |
发表于 9-4-2007 11:14 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 9-4-2007 08:43 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 10-4-2007 01:27 PM
|
显示全部楼层
原帖由 糯米鸡 于 9-4-2007 08:43 PM 发表
先写出你的做的给我们看
对对..自己尝试做做先.. |
|
|
|
|
|
|
|

楼主 |
发表于 12-4-2007 01:02 PM
|
显示全部楼层
1)extern 2)static
1C) union Transport
{
char ... ;
char ... ;
char ... ;
char ... ;
char ... ;
}
1D) struct EmpRec
{
char EmpNum [5];
char Name[30];
struct TransportType Transport;
} |
|
|
|
|
|
|
|

楼主 |
发表于 12-4-2007 01:07 PM
|
显示全部楼层
1E) 48,1,31,-4
1f)floating point number,decimal point, capture the fractional of the calculation
1g)(i)passing by value
(ii)void MulBy5 (int *num)
{ *num (*num *5);
} |
|
|
|
|
|
|
|
发表于 14-4-2007 02:14 AM
|
显示全部楼层
你自己都会做嘛。。。
只是1B,我可能会放unsigned..  |
|
|
|
|
|
|
|

楼主 |
发表于 14-4-2007 11:13 AM
|
显示全部楼层
因为我不懂我的是否完全正确....所以需要你们的来参考!!
还有就是,(1i)(1j)我不会做勒... |
|
|
|
|
|
|
| |
本周最热论坛帖子
|