-3

Hi I've done these lines of code on freepascal:

type bigNum=string;
function bigMod(a:bigNum;b:longint):longint;
var i,hold:longint;
begin
hold:=0;
for i:=1 to length(a) do
    hold:=(ord(a[i])-48+hold*10)mod b;
    bigMod:=hold;
end;
uses sysutils;
var a,i,n:longint;
begin
readln(n);
a:=1;
for i:=1 to n-2 do
    a:=a*2;
IntToStr(a);
writeln(bigMod(bigMod(a,n),1000000000));
end.

but when I run it, it said 'BEGIN' expected but 'USES' found, what should I do to fix it? if i change 'BEGIN' on top of 'USES' its will be another error

  • 1
    Please, do not put code at an off-site location (that cannot be reached in this case). Edit your question and insert the code here. But before you do that, strip the code down to a minimal, just small enough to express the error. – LU RD Sep 05 '18 at 05:12
  • when I tried to give codes in here it somehow said that some of I aren't actual codes but when I put on free pascal it said errors – CodingNewbie Sep 05 '18 at 05:19
  • Without code, this question cannot be answered. – LU RD Sep 05 '18 at 05:29
  • Show a [mcve]. Also, read the error message. What do you think it means, and what does that imply for how to understand the problem. – David Heffernan Sep 05 '18 at 06:23
  • If you can't provide a [mcve] it's best that you remove this post – David Heffernan Sep 05 '18 at 10:52

1 Answers1

0

The uses clause must appear after the (optional) program statement, but before any other statement. Move the uses clause to the top of the code, immediately after the program statement if indeed you have one.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Can you answer my other problem please? when i do your answer actually i worked but there is an 'IntToString' code block but why it still says it expected 'ShortString'? I thought that code would change identifier a from longInt to ShortString – CodingNewbie Sep 05 '18 at 11:49
  • IntToStr is a function. It returns a string. It can't change the type of a variable. It doesn't modify its argument. – David Heffernan Sep 05 '18 at 12:38
  • So can you change the type of a variable? – CodingNewbie Sep 05 '18 at 16:41
  • No, you cannot change the type of a variable. You declared `a` to be `longint` and it is `longint` forever. When you call `IntToStr`, it is a function that returns a `string` containing the decimal representation of the integer that you passed as argument to the function. – David Heffernan Sep 05 '18 at 16:46
  • Sorry to make you feel annoying and drive this question to a whole new question but what can i do to fix it? You see bigNum is in string so 'a' needs to be in string too for the function but when i do that its impossible now to do 'a:=a*2' i don't think ord() and chr() will work because number would be too big to do chr() – CodingNewbie Sep 05 '18 at 16:58
  • You can use more than one variable. And these variables don't have to have the same type. Think about that and see if you can solve the problem. – David Heffernan Sep 05 '18 at 18:15