Sheet 1

You might also like

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

South Valley University

Faculty of Energy Engineering


Programming Languages

2011/2012
Sheet No.1

1- Specify the input and the output of the following simple problems and write an algorithm for
each:
a. Assuming a1b2 - a2b1 0, solve the following linear equations:
a1X1 + b1X2 = c1

a2X1 + b2X2=c2

-----------------------------------------------------------------b c b c
a c a2 c1
X2 = 1 2
Note: X 1 = 2 1 1 2
a1b2 a2b1
a1b2 a2 b1
-----------------------------------------------------------------b. Calculate the average and the standard deviation (SD) of a three numbers, X1, X2 and X3:
------------------------------------------------------------------------2
2
2
2
+ X2+ X3 3X
X1 + X 2 + X 3
X
2
1
, SD =
Note: X =
3
3
------------------------------------------------------------------------c. Find the current i in a series circuit consists of a resistor R , inductance of L H and a
capacitor of C farads. If the voltage across the circuit is E at f Hz.
------------------------------------------E
Note: i =
2
(2f )2 LC 1
2

R +

2fc

------------------------------------------2- Analyze and write an algorithm for the following problems:


a. Find the sum (S) and the average of n numbers.
b. Find the smallest (SML) and the largest (LRG) number in n numbers
c. Compute the following functions to an accuracy :
x2 x3
+
+L
1. e x = 1 + x +
2! 3!
x3 x5 x7
2. sin( x) = x + + L
3! 5! 7!
x2 x4 x6
3. cos( x) = 1
+

+L
2! 4! 6!

1/2

0< x <
1
4. f1 ( x) =
priod = 2 ,
< x < 2
1
is approximated by:
4
sin 3 x sin 5 x sin 7 x sin 9 x
+
+
+
f 2 ( x) = sin x +
,
3
5
7
9

find the percentage error of the approximation for any x, where:


f ( x) f 2 ( x)
%error = 1
100 % .
f1 ( x )

2/2

You might also like