[SOLVED] 代写 C algorithm UNIVERSITY OF MACAU

30 $

File Name: 代写_C_algorithm_UNIVERSITY_OF_MACAU.zip
File Size: 357.96 KB

SKU: 2298599382 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


UNIVERSITY OF MACAU
FACULTY OF BUSINESS ADMINISTRATION
ISOM 3029Computer Programming Using C
Midterm Examination
Fall Semester 20192020
Time allowed: 1.5 hours

Instructions:
Please write down your Student Name, Student ID, Session Number and Seat Number on the question paper and the answer booklet. Please put all your answers on the ANSWER BOOKLET provided.No grades will be given to those answers marked on this question paper.
This is a closedbook exam. NEITHER dictionaries NOR calculators are allowed.
There are 3 parts in this exam paper and the full mark is 100, plus bonus mark 5.
All kinds of CHEATING found during the exam will result in a Grade F.
During the examination, please SWITCH OFF all your communication devices.
Good luck!
Part ATrue or False 20: Answer all the questions.
If the statement is true, write a T without explanation.
However, if the statement is false, indicate it with an F and you have to EXPLAIN WHY it is false.Only 1 will be given to those correct answers without explanation.

In C, a character is stored in one byte of storage space.
After you compile a source program, which is a .cpp file, you will get an executable .exe file.
C considers the variables mark and MARK to be identical.
The default case should always be added to the switch selection statement.
A variable that is known only within the function to which it is defined is called a global variable.
The arithmetic operators , , ,andall have the same level of precedence.
When it is not known in advance how many times a set of statements will be repeated, no value can be used to terminate the repetition.
The word right will justify the output to the righthand side on the console.
The largest integer value that you can store in a data type short int or simply short is 32767.
From the two statements: char cha; coutch;you will get the output b.
Part BMultiple Choice 30: Choose the best answer for each question.
What is the major source of runtime errors?
Code incorrectly compiled.
Bad hardware.
User incorrectly specified requirements.
Assuming the program is doing what it is supposed to do.

The proper approach to debugging code involves the following EXCEPT .
using debugging tools available in your development system.
modifying the code to try and make the error vanish.
adding output statements to show which clause was executed.
adding output statements where data has been changed.

The following are all examples of what type of error?
incorrectly implemented algorithm
used a variable before assigning a value to it
swapped two parameters of the same type on a function call
forgot to designate the output parameter of a function as a reference parameter
runtime error
compile error
logical error
system error

The signature of a function consists of .
parameter list
function name
function name and parameter list
return type, function name, and parameter list

What is the output of the following code?
string sabcdefg;
couts.substr1, 4;

A.ad
B.a
C.bcde
D.cdef

What do the following statements do?
ifstream stream;
stream.openscores.txt;
A.Open a file for input.
B.Open a file for output, the statement fails if the file already exists.
C.Open a file for output, the contents of the file is destroyed if the file already exists.
D.Open a file for input, the statement fails if the file does not exist.
Suppose x10 and y10, what is the value of x when evaluating the expression y10x10?
9
10
11
True

What is the output of the following code?
bool gendertrue;
coutgender ? male : femaleendl;
true
false
female
male

What is the printout of the following switch statement in C?
char chb;
switch ch
case a:
case A:coutchendl; break;
case b:
case B:coutchendl; break;
case c:
case C: coutchendl; break;
case d:
case D:coutchendl;

a
b
B
nothing will be printed out

Express the algebraic equation yax37 in a C statement.
yax37
yaxxx7
ya x37
yax37

What is the value for the variable sum after the following loop statement terminates?
int sum0;
int count0;
do
count;
sumcount;
if sum8 break;

while count5;
5
6
7
10

Analyze the following code.
int count0;
while count100
Point A
coutWelcome to C!endl;
count;
Point B

Point C
count100 is always false at Point B
count100 is always true at Point A
count100 is always true at Point B
count100 is always true at Point C

If a max function is used to find the max of two integers, if you want to use the same function to find the max of two floating point number, such methodology is called:
Overwriting
Overloading
Overriding
Inline

The variables that are declared outside all functions and are accessible to all functions in its scope are called:
Static variables
Dynamic variables
Local variables
Global variables

What will be the output of the following short program
include iostream
using namespace std;
int v120;
int main

int v110;
coutVariable v1 is v1endl;
coutVariable v1 is ::v1endl;
return 0;

10, 20
10, 10
11, 20
20, 11

Part CProblem Solving 50: Answer all the questions.
What values are assigned to the variables in the following sequence of C statements? State the content of each variable on each line.10
int A8;
A2;
int BA;
int C3A3B;
int DB ! CAB3C;
int EAB ? A : C;

Refer to the following C program codes, what will be the output for each case?15
2a

void DoPrintchar x, int y
while y0
coutx;
y;

coutendl;

int main
int i3;coutiendl;
DoPrintA, i;
coutFinished printing itimes!endl;
return 0;

2b

string sHELLO;
s1A;
coutsendl;

2c
include iostream
using namespace std;

int main
int first1;
int second2;
firstsecond;
coutThe first number is first and the second number is secondendl;return 0;

What isare wrong with the following C program codes? Correct them if possible.15
3aint sum0;
int count0;
while count100
sumcountcount;

3b if age18 ;
coutAge is greater than or equal to 18endl;
else;
coutAge is less than 18endl;

3c The following code should output the odd integers from 99 to 1:
for x99; x1; x2
coutxendl;

a What is the objective of the following program? 5

b Please show the output when the number input is 35.5

include iostream
using namespace std;

int main

int number, i;
bool Testingtrue;

coutEnter an integer: ;
cinnumber;

for i2; inumberTesting; i

if numberi0
Testingfalse;

coutCounter is iendl;

if Testing
coutnumber is a prime number!endl;
else
coutnumber is not a prime number!endl;
return 0;

Part DBonus Question 5
Write a C program to print the first 50 positive even numbers excluding zero to a text file named outfile.txt using a while loop.Print the word DONE! on the output screen of your computer when the program terminates.

Use the following names for your variables:outputfile; count; number;
The output in the text file should contain 5 integers per line.

PAGE 7 NUMPAGES 7

Student Name:Student No. :Session No.:Seat No.:

PagePAGE 1 NUMPAGES 1

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C algorithm UNIVERSITY OF MACAU
30 $