This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I am learning pascal and my code is not compiling... Could someone help me??
I have tried in a few online compilers, but them all return an error.
Thanks in advance!
PROCEDURE ProcSoma (A: INTEGER, SOMA: INTEGER);
BEGIN
SOMA:=SOMA+A;
A:=A+1;
END;
BEGIN
VAR I,HI,SOMA:INTEGER;
HI:=31;
SOMA:=0;
FOR I:=1 TO HI STEP 1 DO
IF (I MOD 2 = 1) THEN ProcSoma(ref I, ref SOMA)
ELSE ProcSoma(ref I, SOMA);
WRITELN(SOMA);
END.
In Pascal, the delimiter betweeen parameters in a procedure declaration is ;, not ,.
Related
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I wrote this code:
def sumeven (i)
result = 0
while i < 100
if i % 2 == 0
result += i
end
i += 1
end
result
end
How do I give the i for the equation? When I run the equation in the terminal (mac), I get no output because I'm unable to figure out how to substitute the i for a number. Substituting the "i" with a number in the text editor still gives no output.
Try:
def sumeven(i)
# method implementation...
end
# call the method, passing it an argument
sumeven(4)
If this actually answers your question, may I suggest taking a tiny step back and reading a book on ruby before you get too much farther? You are asking why the car doesn't go before you know how to use the gas pedal.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Is there any method available in ruby 1.8.6 for calculating n values n power?
Like 2 has 5 power then answer is 32 and 5 has 3 power then answer is 125?
2**5 will give you the result 32.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Today I had a really hard time programming in ruby. I came upon this question, and I was really stumped.
Print a sequence of number pairs "x,y" such that x ranges from 0 to 3 and y from 5 to 7 *
I already submitted my answer, but I'm not quite sure if I got it right. I'd just like my question answered now for the sake of understanding.
Something simple like
p [*0..3].product([*5..7])
0.upto 3 do |x|
5.upto 7 {|y| puts x, y}
end
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have this regex:
diff.\*\n.\*\n.\*\n.\*\n.\*\n
I want to match everything from the word "diff" to the fifth new line. Can someone simplify it for me?
You need grouping:
diff(?:.*\n){5}
I think you are asking for this:
/diff(.*\n){5}/
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
Mathematica 8.0.1 on Mac OS X 10.7.2 does this: Quit the kernel and execute
MathieuS[MathieuCharacteristicA[ 1, -(1/4)], -0.25`, 15.707963267948966`]
MathieuS[MathieuCharacteristicA[ 1, -(1/4)], -0.25`, 15.707963267948966`]
(*
5.10119 10^-15
MathieuS[MathieuCharacteristicA[1, -(1/4)], -0.25, 15.708]
*)
That is, the first time it numerically evaluates the expression, while the second time it returns the unevaluated form.
Why? Or have I just spent too long staring at my screen and am doing something stupid?