PW Computer Science 2 (2024) Sub-group 2 of G-REE 03 طاقات متجددة
مخطط الموضوع
-
-
- Teacher: Oussama Zeghba
- Contacts: oussama.zeghba@univ-msila.dz
- Availability :
Tuesday 8:00 a.m. to 5:00 p.m.
Wednesday 8:00 a.m. to 3:30 p.m.- Unit: Practical work of Computer Science
- Hourly volume of personal work required/week: 1.5 hours
- Evaluation method: Quiz and test in class
-
-
-
الاختبارمفتوح: Saturday، 4 May 2024، 9:00 PMمغلق: Saturday، 4 May 2024، 9:40 PM
-
-
-
program the_sum;
var i,X,A,B:integer;
begin
writeln('give A');
readln(A);
writeln('give B');
readln(B);
X:=0;
for i:=A to B do
begin
X:=X+i;
end;
writeln('The sum of the numbers between two values A and B is ',X);
end.
-
-
-
program Exe_3;
var a,b,n,x,S : integer;
begin
writeln('give A');
readln(A);
writeln('give B');
readln(B);
for s:=A to B do
begin
x:= s mod 2;
if x=0 then
writeln(s,' is even')
else
writeln(s,' is odd');
end;
end.
-
-
-
program fact;
var n,x,b:integer;
begin
writeln('give b =');
readln(b);
x:=1;
for n:=2 to b do
begin
x:=x*n;
end;
writeln(' the factorial of ' ,b,' is ',x);
end.
-
-
-
program Taylor_Ex;
uses math;
var n,k: integer;
x,fact,ex,d ,z,s:real;
begin
writeln('give n and x');
readln(n,x);
fact:=1;
s:=0;
for k:=1 to n do
begin
fact:=fact*k;
d:=power(x,k);
z:=d/fact;
s:=s+z
end;
ex:=1+s;
writeln(ex)
end.
-
-
-
program Ex06;
var n,k: integer;
Sn:real;
begin
writeln('give n ');
readln(n);
Sn:=0;
for k:=0 to n do
begin
Sn:=Sn+(k/(2*k+1))
end;
writeln(Sn)
end.
-
-
-
The FIBONACCI sequence
program FIBONOCCI;
uses crt;
var k,n,u1,u2,un: integer;
begin
clrscr;
writeln('give n and x');
readln(n);
u1:=1;
u2:=1;
for k:=2 to n do
begin
un:=u1+u2;
u1:=u2;
u2:=un;
end;
writeln('un = ',un);
end.
-
-
-
program GCD ;
var a , b : integer ;
begin
write('Give the value of a = ') ;
readln(a) ;
write('Give the value of b = ') ;
readln(b) ;
while a<>b do
begin
if a>b then
a:=a-b
else
b:=b-a ;
end ;
writeln('the GCD is ', a) ;
end.
-
-
-
program uppercas;
var
lower, upper : char;
begin
// Convert a lower case letter to upper case
lower := 'g';
upper := UpCase(lower);
// Display these letters
writeln('lower = '+lower+' upper = '+upper);
end.
-
-
-
program PermuteCharacters;
var
str: string;
i: integer;
temp: char;
begin
write('Enter a string: ');
readln(str);
for i := 2 to length(str) do
begin
temp := str[i];
str[i] := str[i - 1];
str[i - 1] := temp;
i:=i+1;
end;
writeln('Result: ', str);
end.
-
-
-
program the sumof a vector;
var T:array[0..3] of integer;
avr:real;
S,Q,i:integer;
begin
S:=0;
for i:=1 to 4 do
begin
writeln(' give the values of T ',i);
readln(T[i])
end;
for q:=1 to 4 do
begin
S:=S+T[i];
end;
writeln('the sum of T is ',S);
end.
-
-
-
program aray2;
uses crt;
var l,max:integer;
n:array [1..5] of integer;
begin
clrscr;
writeln('========================');
for l:=1 to 5 do
begin
write(' Value number-',l,': ');
readln(n[l]);
end;
max:=n[1];
for l:=1 to 5 do
begin
if (n[l]>max) then
max:=n[l];
end;
writeln(' THE Maximum Value IS: ',max);
end.
-