没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
Family Name:
Other Names:
Signature:
Student Number:
This PAPER is NOT to be retained by the STUDENT
The University Of New South Wales
C0MP1911 Final Exam
1337 Computing 1
July 2006
Time allowed: 3 hrs
Total number of questions: 22
Total number of marks: 105
You are permitted one A4 sheet of information.
You must hand in this entire exam paper, your information sheet, and the answer booklets.
otherwise you will get zero marks for the exam and a possible charge of academic misconduct.
Ensure that you fill in all of the details on the front of the info sheet, this pink paper, and the
3 answer booklets, and then SIGN everything. Mark one booklet PART C, one PART D, and
one WORKING ONLY. The working only booklet will not be marked.
Do not use red pen or pencil in this exam. Unless advised otherwise you may not use any
language features or library functions not covered in class. Answers w hich do not c omply with
the course style guide or which introduc e potential security vulnerabilities will b e penalised.
There are two marks for following the examination instructions.
Examiners’ Use Only
Inst A 12 13 14 15 16 C D Total
Part A: Multiple Choice Questions
Answer the questions in this part by circling the correct answer.
For each correct answer you earn 3 marks. There is no penalty for incorrect answers.
Question 1
Which of the following would be the best name for a function to compute the area of a triangle,
defined in a file called Triangle.c entirely devoted to calculating the properties of triangles? The
function is not an interface function.
[A] t
[B] area
[C] trngle
[D] triangle
[E] calculateTheAreaOfATriangle
Question 2
On my machine one of these C types is an integer type which can can store more numbers than
the other integer types listed. Which one?
[A] double
[B] long
[C] int
[D] void
[E] char
Question 3
Which C expression below is equivalent to this C expression: !(x || y)
[A] (!x) || (!y)
[B] (!x) && (!y)
[C] x | y
[D] !( x != y)
[E] !( x == y)
1
Question 4
Consider the following C variable definition:
char s[] = "hello world";
Suppose we wish to make a copy of the string in s and have it referred to by the variable p.
Which of the following C code fragments does this correctly?
[A] char *p; strcpy(p, s);
[B] char *p = NULL; strcpy(p, s);
[C] char *p; p = (char *) malloc(strlen(s)); strcpy(p, s);
[D] All of the above
[E] None of the above
Question 5
Consider the following C program:
#include <stdio.h>
int f(int *x, int y, int *z) {
(*x)++;
y++;
return *z;
}
int main(int argc, char** argv) {
int w = 1;
int x = 2;
int y = 3;
int *z;
z = &w;
printf("w=%d; x=%d; y=%d; z=%p \n", w, x, y, z);
f(z, x, &y);
printf("w=%d; x=%d; y=%d; z=%p \n", w, x, y, z);
return 0;
}
Which variables have a different value printed in the second printf statement?
[A] w only
[B] x only
[C] y only
[D] w and y only
[E] Some other combination
2
Question 6
The following C program compiles correctly and is run.
#include <stdio.h>
int main(int argc, char** argv) {
int x = 7;
printf("%d\n", (1/2) * x);
return 0;
}
What does it print?
[A] 0
[B] 1
[C] 2
[D] 3
[E] 4
Question 7
Given the following structure definitions:
typedef struct {
int x;
int y;
} A;
typedef struct {
int v;
A w;
} B;
If we define a variable p as follows:
B *p;
which one of these is a legal C expression?
[A] p.w.y
[B] p->w.y
[C] p.w->y
[D] p->w->y
[E] p->a->y
3
剩余15页未读,继续阅读
wanwe521
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0