Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Algorithms Design and Programming Techniques Tutorial 3

Tutorial 3
1. Write a C++ program that asks for a temperature in Fahrenheit and
displays it in Celsius. Use the formula:
5
𝐶 0 = (𝐹 − 32)
9

2. Write a C++ program to perform the following equations:


𝑥2 𝑥4
𝐚) 𝑧 = 1 − +
2! 4!
𝑥 3 − 4𝑥 2 + 𝑥
𝐛) 𝑧 = 2
𝑥 + 2𝑥 + 2
𝐜) 𝑧 = [(𝑥 − 𝑦)2 − (𝑥 + 𝑦)]/32

3. Consider the arithmetic expressions


1. a * b / (-c * 31 % 13) * d
2. a * (b * b) – (c * b) + d
Write the order in which the operations will be executed?

4. What is the computation sequence of the following expression


(a + b / (c - 5)) / ((d + 7) / (e - 37) / 3)
if a=10 , b=20 , c=14 , d=8, and e=40.

5. For each the following algebraic expressions write an equivalent C++ arithmetic
expression.
𝑎3 − 𝑏 2
𝐚)
𝑐 2 + 25
1 1 1 1
𝐛) + 2 + 3 + 4
𝑥 𝑥 𝑥 𝑥
𝑡
𝐜) 𝑥 + 𝑦 2 +
𝑧

© Asst. Lect. Wasseem Nahi Ibrahem Page 1


Algorithms Design and Programming Techniques Tutorial 3

6. Determine the values of the variables for each of the following C++ statements:
a) z = x++*y;
b) z = 2*++x*y;
c) x += 4+--y/x---3;
d) y %= x;
Assume that x=4 , y=6. Assume that all variables are integers.

© Asst. Lect. Wasseem Nahi Ibrahem Page 2

You might also like