Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

K L Sum I Condition Sum=sum +L I=i+1 output

3 10 10 0 No 20 1
3 7 20 1 No 27 2
3 1 27 2 Yes 27
Assignment#1
Momen Nabil Zaky AbdelSamad
20215036

Q1
Q2
start
Assign i = 0
Assign x = 1
Assign y = 0
Assign z = 1
Input n
While i<=n
Output y
Assign i = i+1
Assign y = x
Assign x = z
Assign z = x+y
End while
End
Q3

Function Main
Output "plese inter the lengh"
Input l
Assign area = l*l
Assign premeter = 4*l
Output "area = "&area
Output "premeter = "&premeter
End

Q4
Function Main
Input x
Input y
Assign x = x+y
Assign y = x-y
Assign x = x-y
Output x
Output y
End

Q5
Function Main
Declare Integer a, b, c, dis
Declare Real x1, x2

Output "inter a b c"


Input a
Input b
Input c
Assign dis = (b*b)-(4*a*c)
If dis>0
Assign x1 = ((-b)+(sqrt((b*b)-(4*a*c))))/(2*a)
Assign x2 = ((-b)-(sqrt((b*b)-(4*a*c))))/(2*a)
Output x1
Output x2
False:
If dis=0
Assign x1 = -b/(2*a)
Assign x1 = x2
Output x1
Output x2
False:
Assign x1 = -b/(2*a)
Assign x2 = sqrt(-dis)/(2*a)
Output x1&"+"&x2&"i"
Output x1&"-"&x2&"i"
End

Q6
start
Set x, n, m, i, sum
Input x,n
Assign x = -x
Assign sum = -1
Assign i = 0
Assign m = -1
While i<n
Assign m = m*x
Assign i = i+1
Assign sum = sum+m
End
print"sum= "&sum
End

Q7
start
Input x,n
For x=x+1 to n-1
If x%2=0
Sum=sum+x
Print sum
End

Q8
n fact count Fact=fact*count conditio output
n
5 1 1 1 No
5 1 2 2 No
5 2 3 6 No
5 6 4 24 No
5 24 5 120 yes 120

Thanks

You might also like