¿60 minutes - School of Computing and Technology, Eastern

advertisement
EASTERN MEDITERRANEAN UNIVERSITY
School of Computing and Technology
I T E C 1 1 3
Algo. & Prog. Techniques
F a l l 2 0 1 3 - 2 0 1 4
Student Id : …………………………….……
Department of Information Technology
Hourly Exam#1 11/11/2013 60 minutes
Name :……………………………………………… Signature: ..………………………………….…….
Answer as many questions as you can. Clearly state all assumptions you make. Do NOT exchange any materials with
anyone! Turn Off all electronic devices and put them away from yourself.
Q1.Design a pseudocode that computes xn. Prompt the user to enter the value of x and n from keyboard. (25 p)
Ex: Sample input for 4 and 3 your design should calculate 43 4*4*4
Q2.
a)What are the results of the following evaluations? Show the fully parenthesized form of the expression and
show the value of the expression. Assume that: (10 p)
a = 3, b = 2, c = 5;
Expression
a–b*b+c
Fully Parenthesized Expression
Value
(a + b / 2) * c /b
50 / b +50/ c
2*a + 105 % c
10/b*c/5
b) Write a single C statement or line that accomplishes each of the following: (5 p)
i) Print the message “Enter two numbers.”
ii) Assign the product of variables b and c to variable a.
c)Put a check mark in the appropriate column for de following variable names. (10 p)
Variable name
Valid
Invalid
_under_bar_
m928134
if
2hour2
my sales
Q3. What is the output of the flowchart given below for the following list of values. For each case show the
execution path on the flowchart(25 p)
START
a
b
c
?
a<=b
TRUE
FALSE
?
a<c
TRUE
?
b<c
result ßb
FALSE
?
b<c
TRUE
result ßa
TRUE
result ßa
FALSE
TRUE
?
a<c
result ßb
FALSE
FALSE
resultß c
result ßc
result
END
i.
a=1,b=2,c=3
output:
ii.
a=2,b=1,c=3
output:
iii.
a=2,b=3,c=1
output:
iv.
What does this algorithm do?(Bonus 5p)
Q4. Convert the pseudocode shown below to flowchart. (25 p)
DO
DISPLAY “Enter an integer number”
INPUT num
IF num<100 THEN
count1=count1+1;
ELSE
count2=count2+1
ENDIF
WHILE num>0
DISPLAY count1,count2
Download