首页 > > 详细

代写FEEG6002C1程序、C/C++课程编程调试、代做c++实验程序代做R语言编程|代写留学生 Statistics统计、回归、迭代

UNIVERSITY OF SOUTHAMPTON FEEG6002C1
______________________________________________________
SEMESTER 1 ASSESSMENT PAPER 2020/21
Advanced Computational Methods 1
DURATION – 24 hours
______________________________________________________
This paper contains five questions. Answer all questions.
This is an online assessment. The solution document must be
submitted via Blackboard only. Please submit your answers to
all questions using a single word document.
Please use Quincy (free download from below link)
http://www.codecutter.net/tools/quincy/
or use any of the following freely available on-line C compilers
to write, compile and execute C programmes.
https://www.onlinegdb.com/online_c_compiler
https://www.programiz.com/c-programming/online-compiler/
A total of 100 marks are available for this paper.
2 FEEG6002C1
Copyright 2021 v01 © University of Southampton Page 2 of 15
Question 1:
a). Why do you want to work on a remote system (or remote server)?
(3 marks)
b). What is a terminal?
(2 marks)
c). Why do you need a terminal in the Linux operating system?
(2 marks)
d). What is the motivation of using shell scripts in the Linux operating system?
(3 marks)
e). List three different Linux shell types?
(3 marks)
f). What is the motivation of using make files in the Linux operating system?
(3 marks)
g). Explain with steps how to create make files in the Linux operating system?
(4 marks)
h). What is a function in C programming?
(2 marks)
i). C programming offers two types of functions. What are they, and how are they
different?
(2 marks)
j). Show two methods for defining a symbolic constant named MAXIMUM that has a
value of 200.
(2 marks)
k). If a function does not return a value, what type should be used to declare it?
(2 marks)
l). In a one-dimensional array declared with n elements, what is the subscript of the
last element?
(2 marks)
(30 marks)
3 FEEG6002C1
Copyright 2021 v01 © University of Southampton Page 3 of 15
Question 2:
Fill in the blanks in each of the following.
a). The first element of an array has index ______.
b). The ______ operator returns the number of bytes used to store a variable type t.
c). To declare a pointer of type char, you need to use _______.
d). Memory allocation through _______ takes place at run time.
e). C programs consist only of _______.
f). ______ need to be given before the function can be called.
g). If you use constants in a C-program, it is good practice to define a _____.
h). ________ is a special macro representing End Of File.
i). ________ is a valuable function for allowing user input to a C program.
j). With the ______, C program can use alias names of data types that are machine
specific.
(10 Marks)
4 FEEG6002C1
Copyright 2021 v01 © University of Southampton Page 4 of 15
Question 3:
In this question you will develop a set of functions to manipulate 3x3 matrices in
various ways.
a) Write a function print_matrix(…) which takes as an input a two-dimensional
array of size nxn of type double representing a matrix, and an integer n
corresponding to the size of this array. The function should print the elements of this
array to the standard output displaying it in the form of a matrix. For example, we
expect:
1 0
0 1
for a 2x2 array a with elements a[0][0]=1, a[0][1]=0, a[1][0]=0,
a[1][1]=1. The function print_matrix(…) does not return any value.
(2 marks)
b) Write a function transpose(…) which takes as an input a 3x3 array a of type
double representing a matrix, and returns a transpose of this matrix stored in the
same input variable a. Note the transpose of a square matrix 𝑎𝑖𝑗 is defined as:
(𝑎)𝑖𝑗
𝑇 = 𝑎𝑗𝑖.
(2 marks)
c) Write a function det2(…) which takes as an input a 2x2 array a of type
double representing a matrix, and returns a variable of type double equal to the
determinant of the input matrix:
|𝑎| = |
𝑎00 𝑎01
𝑎10 𝑎11
| = 𝑎00𝑎11 − 𝑎01𝑎10.
(2 marks)
d) Write a function cofactor(…) which takes as an input a 3x3 array a of type
double representing a matrix, and two integers i and j, and returns a variable of
type double equal to the cofactor 𝑐𝑖𝑗 of the matrix a. The cofactor 𝑐𝑖𝑗 is defined as:
5 FEEG6002C1
Copyright 2021 v01 © University of Southampton Page 5 of 15
where 𝑚𝑖𝑗 is the minor of the element 𝑎𝑖𝑗 of the 3x3 matrix a, equal to the
determinant of the reduced 2x2 matrix obtained by removing all elements of the ith
row and jth column of the matrix a. Thus the notation 𝑎𝑘𝑙
(𝑖𝑗)
in the above equation
means the elements of the matrix remaining after removing the ith row and jth
column from the matrix a. Use function det2(…) developed above to simplify your
code.
(4 marks)
e) Write a function det3(…) which takes as an input a 3x3 array a of type
double representing a matrix, and returns a variable of type double equal to the
determinant of the input matrix a. To evaluate the determinant |𝑎| of a matrix 𝑎 use
the Laplace expansion method:
|𝑎| = ∑𝑎𝑘𝑖𝑐𝑘𝑖
2
𝑘=0
𝑖 = 0 𝑜𝑟 1 𝑜𝑟 2
where 𝑐𝑘𝑖 is the cofactor of the matrix 𝑎 as defined above. Note that the index i is
fixed and the result is independent of the choice of i. Use the function
cofactor(…) developed as part of the previous question to simplify your code.
(4 marks)
f) Write a function inverse(…) which takes as an input a 3x3 array a of type
double representing a matrix, and returns an inverse of this matrix stored in the
same input variable a. To calculate the inverse matrix 𝑎
−1 of a matrix 𝑎, note that the
elements of the inverse matrix can be expressed as:
where 𝑐𝑖𝑗 denotes the cofactor of the matrix a and |𝑎| is the determinant of the matrix
a. Use your functions det3(…) and cofactor(…) developed above to simplify
your code.
(4 marks)
g) Write a function multiply(…) which takes as an input two 3x3 arrays of type
double representing two matrices. The function should calculate the matrix product
of the two matrices and print it to the standard output using the function
print_matrix(…) developed above. The function multiply(…) does not
return any value.
(2 marks)
6 FEEG6002C1
Copyright 2021 v01 © University of Southampton Page 6 of 15
Example of incomplete function main() could look like this:
int main(void)
{


printf("\nOriginal matrix:\n");
print_matrix(3, a);
printf("Determinant of the matrix:\n");
printf("%f\n", det3(a));
printf("\nTranspose of the matrix:\n");
transpose(a);
print_matrix(3, a);
printf("Inverse of the matrix:\n");
transpose(a); // transpose back to obtain original
matrix
for(i=0; i

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2
热点文章
程序代写更多图片

联系我们 - QQ: 99515681 微信:codinghelp2
© 2014 www.7daixie.com
程序代写网!