0% found this document useful (0 votes)
23 views1 page

The Lebanese University

This document contains 5 questions regarding algorithms and pseudo code for an Introduction to Algorithms course. Question 1 asks to write pseudo code and a flow chart to determine if two integers have the same sign, opposite signs, or are equal. Question 2 asks to write pseudo code and a flow chart to add all odd numbers between 0 and 50. Question 3 asks about the differences between while, do-while, and for loops and what the break statement does. Question 4 asks to evaluate two mathematical expressions where one is boolean and one is mathematical. Question 5 asks to determine the output of a sample program and draw its flow chart.

Uploaded by

Anis Hijazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

The Lebanese University

This document contains 5 questions regarding algorithms and pseudo code for an Introduction to Algorithms course. Question 1 asks to write pseudo code and a flow chart to determine if two integers have the same sign, opposite signs, or are equal. Question 2 asks to write pseudo code and a flow chart to add all odd numbers between 0 and 50. Question 3 asks about the differences between while, do-while, and for loops and what the break statement does. Question 4 asks to evaluate two mathematical expressions where one is boolean and one is mathematical. Question 5 asks to determine the output of a sample program and draw its flow chart.

Uploaded by

Anis Hijazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

The Lebanese University

Faculty of Economics and Business Administration (first Branch)


Subject: Introduction to Algorithm Year: 2009-2010
Duration: 60 Min. Instructor: Ali Saleh

Question #1 (7pts)
a) Write a pseudo code to input a pair of integers and determine if they are equal, have opposite signs
(one negative and the other positive), or the same sign. Print out a message, either “Equal”,
“Opposite Signs”, or “Same Sign”, for the appropriate case.
b) Draw a flow chart for the above pseudo code.

Question #2 (7 pts)
a) Write a pseudo code that adds all odd numbers between 0 and 50.
b) Draw a flow chart for the above pseudo code.

Question #3 (5 pts)
a) What is the difference between pretest loop (while), the post test loop (do while), and the FOR
loop?
b) What does the BREAK statement do?

Question #4 (4 pts)
Evaluate the following expressions. Also mark which expression is Boolean and which is
mathematical:
a) (x-2)/2*y-3 < (y*x-3)/2*2 where x=5 and y=-3
b) w=(2*z-25)/2+3*z where z=8

Question #5 (7 pts)
a) Determine the output of the following program assuming that the user enters 5 for the value N.
main program
Declare A , i, N, term as Integer
Declare acc as Real
Begin
Write "Enter an integer"
Input (N)
A=4
i=1
acc = 0
do
Term = A + i
acc = acc + term / (N- i + 1)
Write "Term (", i ,")=", Term
i=i+1
while (i <= N)
Write "The result is : ", acc
Write "Number of iterations: ", i - 1
Write "--------------- THE END ----------------"
End

b) Draw the flow chart of the above pseudo code.

Good Luck

You might also like