首页 > > 详细

辅导ELEC362程序、讲解C++程序、C++编程设计调试 调试Matlab程序|调试Matlab程序

项目预算:   开发周期:  发布时间:   要求地区:
PAPER CODE ....................ELEC362...............PAGE....1........OF ..............4..........................CONTINUED
MOCK EXAM PAPER
(Open book test)
Application development with C++
TIME ALLOWED: 3 Hours
INSTRUCTIONS TO CANDIDATES
The numbers in the right hand margin represent an approximate guide to the marks available
for that question (or part of a question). Total marks available are 100.
For all questions requiring a code, make sure the code is well commented as comments are
part of the total mark of the code.
For all questions requiring a code, the code submitted in the answer sheet must be machine
readable (copy and paste the code into your answer sheet).
Answer ALL Questions.
PAPER CODE ....................ELEC362...............PAGE....2........OF ..............4..........................CONTINUED
1 a) Write a C++ programme that reads a sentence, input by the user and displays a
breakdown of how many each letter in the English alphabets was repeated. For
example, the sentence “how are you” will display:
25
a appeared 1 time/s
b appeared 0 time/s
c appeared 0 time/s
d appeared 0 time/s
e appeared 1 time/s
The list continues for the 26 letters. You can assume the following simplifications
about the input to the programme:
-All letters are lower case.
-No symbols or numbers will be in the sentence.
- No error handling is required.
b) Draw a flow chart of an algorithm you propose for a C++ programme used to book
a flight ticket. The programme will be used by a travel agent to do the following
tasks (no code is required):
10
- List all passengers on a given flight.
- Retrieve information of a passenger.
Total
35
PAPER CODE ....................ELEC362...............PAGE....3........OF ..............4..........................CONTINUED
2. a) Explain the process of generating an executable file from the source code files. 6
b) Explain what friend functions are used for. 6
c) Define what the destructor of a class is, give an example of what it can be used for
(no code is required).
4
d) You are given the following code, specify whether the variables are allocated on static
or dynamic memory:
int i{ }; 2
int &r=i; 2
double Array[5]; 2
char *letter{nullptr}; 2
int *number= new int(0); 2
vector data; 2
Total
28
PAPER CODE ....................ELEC362...............PAGE....4........OF ..............4..........................END
3. a) Explain the difference between a vector and a list? Give an example of a situation
where a list is more suitable than a vector in a code. What is the main disadvantage
of using a list over a vector? (No code is required).
7
b) From basic datatypes, create a class “Sphere” and a class “Cube”, which are
used to describe geometrical shapes to be used in a CAD programme. The
following code from the main function will be run to test your code. The
comment in every line explains the used function or operator, etc.
30
Cube Cube1; // Initialising a cube with side length of 1
Sphere Sph1(5); // Initialising a sphere with radius 5
Cube1.setSide(5); // changes the side length of Cube1 to 5
cout << "The surface Area of Cube1 is " << Cube1.SurfArea()<<" and the
surface area of Sph1 is " << Sph1.SurfArea()<< endl;
// The function SurfArea() returns the surface area of the shape
double TotVol = Cube1.Vol() + Sph1.Vol();
// Adds the volumes of the shapes, the function Vol() gives the volume
of the shape
cout << "The total volume is "<< TotVol;
The output of this code when it runs should be:
The surface Area of Cube1 is 150 and the Surface Area of Sph1
is 314.159
The total volume is 648.598
No error handling is required. For simplicity you can define the entire code
in a single file (header files are not needed).
Total
37

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!