May 14, 200917 yr Ok, I gets it naow. program pr4; var a,b,c:integer; begin readln(a); readln(b); if a>b then c:=1 else c:=0; writeln©; readln; end. Never put a ; right before else, it won't wanna work. Also, you can left out the else part, if you don't need it. Like: program pr5; var a,b,c,:integer; begin readln(a); readln(b); if a<0 then a:=a*(-1); c:=a+b; writeln©; readln; end. Variables don't have to be called by only one letter, you can call them abc or whatever if you want. Also, try deleting the last readln and run the program to see what happens.
May 14, 200917 yr Author Ok, I gets it naow. You talked just like me agains! :cheesy: Also, try deleting the last readln and run the program to see what happens. Ewwwww. That isn't good.
May 14, 200917 yr On some competitions we have to leave out the last readln. Maybe I'll explain it later. :thinking: Are you having fun? :D
May 14, 200917 yr Author Why isn't this STILL their thread? Because theoretically, other people are supposed to join in on our Intellectual Discourse. :P
May 14, 200917 yr Oh, you...! :P program pr6; var n,i,x,s:integer; begin readln(n); for i:=1 to n do begin readln(x); s:=s+x; end; writeln(s); readln; end. See the yellow part? Well, you can also type the program like this: program pr6; var n,i,x,s:integer; begin readln(n); for i:=1 to n do begin readln(x); s:=s+x; end; writeln(s); readln; end. It doesn't matter. Edit: forum fail. Consider the _ as a space. program pr6; var n,i,x,s:integer; begin readln(n); for i:=1 to n do _begin __readln(x); __s:=s+x; _end; writeln(s); readln; end.
May 14, 200917 yr Author Okay. That makes sense, because with the space indents, you can, like... organize it better, visually. yeah. edit: what does "for i:=1 to n do" mean? :huh: edit two: also you typed your program wrong I think :P did you mean "s:=i+x;" instead of "s:=s+x;"?
May 14, 200917 yr It's a loop that repeats n times. But you can put, for example, for i:=2 to 5 do s:=s+i; I don't know if you noticed, but I put another begin and end in my previous post. If in a loop or under an if/else, or something other (I can't tell you everything now!), exists more than 1 command, you need an extra begin-end. That said, I don't need it in this post. But I could've put it, no harm will be done.
May 14, 200917 yr Author But... but but it didn't do what it was supposed to do when I tried it. Or maybe I just don't know what it's supposed to do :lol:
May 14, 200917 yr Author Exactly what I was thinking :lol: What was that program SUPPOSED to do? Wasn't it supposed to, like........ add stuff? O_o
May 14, 200917 yr Eh. My bad. I guess my brain is shut down by now. :lol: program pr6; var n,i,x,s:integer; begin readln(n); s:=0; for i:=1 to n do begin readln(x); s:=s+x; end; writeln(s); readln; end.
June 8, 200917 yr *saves thread from the depths of The Lounge* Still remember what I've learned you? Can we move on? :D
Create an account or sign in to comment