lOMoARcPSD|64026470
Office Use Only
Monash University
Semester One Examination Period
2014
Faculty Of Engineering
EXAM CODES: ECE2071
TITLE OF PAPER: COMPUTER ORGANISATION AND PROGRAMMING
EXAM DURATION: 3 hours writing time
READING TIME: 10 minutes
THIS PAPER IS FOR STUDENTS STUDYING AT:( tick where applicable)
! Berwick " Clayton " Malaysia ! Off Campus Learning ! Open Learning
! Caulfield ! Gippsland ! Peninsula ! Enhancement Studies ! Sth Africa
! Pharmacy ! Other (specify)
During an exam, you must not have in your possession, a book, notes, paper, calculator,
pencil case, mobile phone or other material/item which has not been authorised for the exam
or specifically permitted as noted below. Any material or item on your desk, chair or person
will be deemed to be in your possession. You are reminded that possession of unauthorised
materials in an exam is a discipline offence under Monash Statute 4.1.
1. Attempt ALL questions. Candidates are asked to answer all questions in the
spaces provided in the examination paper. This paper consists of 5 questions.
2. Exam paper is printed on single sided paper. Therefore, use the reverse side of
any of these pages as scrap paper for any working or calculations that are
required in deriving your answers. THESE WORKINGS HOWEVER WILL
NOT CARRY ANY MARKS TOWARDS YOUR FINAL ANSWERS.
3. The last two pages contain tables related to MIPS microprocessor which you
may find useful in answering these questions
AUTHORISED MATERIALS
CALCULATORS ! YES " NO
OPEN BOOK ! YES " NO
SPECIFICALLY PERMITTED ITEMS ! YES " NO
Q1 Q2 Q3 Q4 Q5 Total Marks
Candidates must complete this section if required to write answers within this paper
STUDENT ID __ __ __ __ __ __ __ __ DESK NUMBER __ __
__ __
messages.downloaded_by
, lOMoARcPSD|64026470
QUESTION 1 (20 marks)
Q1.1 (7 marks)
In the following C program, the value of x depends on the scope rules. Give the result
of each printf() statement in the “Your Answer” column.
Your Answer
#include <stdio.h>
void func1(int m);
void func2();
int func3();
void func4(int *n);
int m = 10;
int main(){
func1(20);
printf("A %d\n",m); A 13
int m;
m = func3();
printf("B %d\n",m); B8
func4(&m);
printf("C %d\n",m); C 38
return 0;
}
void func1(int m){
printf("D %d\n",m); D 20
func2();
}
void func2(){
int n;
for (n=0;n<3;n++) m +=n;
}
int func3(){
printf("E %d\n",m); E 13
int m = 4;
printf("F %d\n",m); F4
return m*2;
}
void func4(int *n){
*n = 25 + m;
printf("G %d\n",m); G 13
}
messages.downloaded_by
Office Use Only
Monash University
Semester One Examination Period
2014
Faculty Of Engineering
EXAM CODES: ECE2071
TITLE OF PAPER: COMPUTER ORGANISATION AND PROGRAMMING
EXAM DURATION: 3 hours writing time
READING TIME: 10 minutes
THIS PAPER IS FOR STUDENTS STUDYING AT:( tick where applicable)
! Berwick " Clayton " Malaysia ! Off Campus Learning ! Open Learning
! Caulfield ! Gippsland ! Peninsula ! Enhancement Studies ! Sth Africa
! Pharmacy ! Other (specify)
During an exam, you must not have in your possession, a book, notes, paper, calculator,
pencil case, mobile phone or other material/item which has not been authorised for the exam
or specifically permitted as noted below. Any material or item on your desk, chair or person
will be deemed to be in your possession. You are reminded that possession of unauthorised
materials in an exam is a discipline offence under Monash Statute 4.1.
1. Attempt ALL questions. Candidates are asked to answer all questions in the
spaces provided in the examination paper. This paper consists of 5 questions.
2. Exam paper is printed on single sided paper. Therefore, use the reverse side of
any of these pages as scrap paper for any working or calculations that are
required in deriving your answers. THESE WORKINGS HOWEVER WILL
NOT CARRY ANY MARKS TOWARDS YOUR FINAL ANSWERS.
3. The last two pages contain tables related to MIPS microprocessor which you
may find useful in answering these questions
AUTHORISED MATERIALS
CALCULATORS ! YES " NO
OPEN BOOK ! YES " NO
SPECIFICALLY PERMITTED ITEMS ! YES " NO
Q1 Q2 Q3 Q4 Q5 Total Marks
Candidates must complete this section if required to write answers within this paper
STUDENT ID __ __ __ __ __ __ __ __ DESK NUMBER __ __
__ __
messages.downloaded_by
, lOMoARcPSD|64026470
QUESTION 1 (20 marks)
Q1.1 (7 marks)
In the following C program, the value of x depends on the scope rules. Give the result
of each printf() statement in the “Your Answer” column.
Your Answer
#include <stdio.h>
void func1(int m);
void func2();
int func3();
void func4(int *n);
int m = 10;
int main(){
func1(20);
printf("A %d\n",m); A 13
int m;
m = func3();
printf("B %d\n",m); B8
func4(&m);
printf("C %d\n",m); C 38
return 0;
}
void func1(int m){
printf("D %d\n",m); D 20
func2();
}
void func2(){
int n;
for (n=0;n<3;n++) m +=n;
}
int func3(){
printf("E %d\n",m); E 13
int m = 4;
printf("F %d\n",m); F4
return m*2;
}
void func4(int *n){
*n = 25 + m;
printf("G %d\n",m); G 13
}
messages.downloaded_by