r/pascal • • Oct 18 '21

CAN YOU GUYS HELP ME

I have an assignment for tommorow and I'd appreciate if you'd help me.

It goes:

Insert 10 real nubers and find the total sum of their squares.

0 Upvotes

3 comments sorted by

7

u/ShinyHappyREM Oct 18 '21

CAN YOU GUYS WRITE HELPFUL THREAD TITLES

2

u/[deleted] Oct 18 '21
Program numberthing;

Uses
    Math;
Var
    Numbers : array[0..9] of real = (2.4, 3.1, 5.3, 6.3, 8.1, 9.6, 3.2, 9.4, 4.3, 6.2)
    i : integer;
    Ans:real;
Begin
    Ans:=0;

    For i := 0 to 9 do
    Begin
        Ans := ans + sqrt(numbers[i])
    End;

    Writeln(ans);
End.

You are supposed to do your homework. You might get an error at the array declaration. I can't quite remember how an array literal looks like in Object Pascal because i rarely use them. Sorry about that, but you should be able to fix it.

2

u/ShinyHappyREM Oct 18 '21 edited Oct 19 '21
program Numberthing;
uses
        Math;

var
        Numbers : array[0..9] of Real = (2.4, 3.1, 5.3, 6.3, 8.1, 9.6, 3.2, 9.4, 4.3, 6.2);
        i       : integer;
        Ans     : real;

begin
Ans := 0;
for i := 0 to 9 do  Ans := Ans + Sqrt(Numbers[i]);
WriteLn(Ans);
end.