Tell me, please, why in variable mode in Pascal the variable is not displayed when I write outtextxy(x,y,p[i]); while p is an integer array.

Update

What am I doing wrong, tell me, please. With this code, only the last element is output, i.e. when i=k :

 uses crt,graph; var k,i,m,dr,md:integer; pr,par:string; p:array[1..100] of real; BEGIN readln(k); for i:=1 to k do readln(p[i]); initgraph(dr,md,' '); for i:=1 to k do str(p[i],pr); for i:=1 to k do begin str(i,par); setcolor(i); outtextxy(100+80*(i-1),430,pr[i]); outtextxy(100+80*(i-1),440,par[i]); readln; end; END. 
  • @VeFox, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

2 answers 2

Perhaps, output the background color and just can not see the output.
The item with index i may be missing from the array.
Perhaps you do not see the conclusion, because x or y go beyond the screen.
Perhaps not activated graphics mode or something else.

Update

In my opinion, you have everything displayed on the same places on the screen. You do not change the coordinate of y. Therefore, you see only the last displayed value. By the way, why is there readln? I do not remember pascal, but, in my opinion, readln is used to read the entered values. To change the lines in the graphical mode, use the change of the y coordinate.

Update

Yes you are right. What happens when you output pr [i]? In the str (i, par) line, you translated counter i from integer to string and assigned the value to par. What do you want to get from a string consisting of one character with an index greater than 1? Does str (), when passing the second parameter of a non-empty string to it, append it instead of the banal assignment of a new value?

  • What am I doing wrong, tell me, please. With this code, only the last element is output, i.e. when i = k: uses crt, graph; var k, i, m, dr, md: integer; pr, par: string; p: array [1..100] of real; BEGIN readln (k); for i: = 1 to k do readln (p [i]); initgraph (dr, md, ''); for i: = 1 to k do str (p [i], pr); for i: = 1 to k do begin str (i, par); setcolor (i); outtextxy (100 + 80 * (i-1), 430, pr [i]); outtextxy (100 + 80 * (i-1), 440, par [i]); readln; end; End. - VeFox
  • Format the code by selecting it and clicking on the {} icon above the text entry field. - Get
  • What is the point of changing y, if in the end I just have to make a line (located just at this very u). It can not overlap for one simple reason, there are different x. - VeFox
  • Updated the answer - Get
 for i:=1 to k do str(p[i],pr[i]); // здесь забыли дописать [i] к pr, если я правильно понял. 

Using strings to store arrays is bad form. Correctly declare pr and par as array [1..100] of string .

Better yet, write like this:

 var ElementsCount: Integer; i, m, dr, md: Integer; pr, par: string; p: array [1..100] of real; BEGIN ReadLn(ElementsCount); // что будет, если напишут букву вместо цифры? Или 101? for i := 1 to ElementsCount do ReadLn(p[i]); // что будет, если напишут букву вместо цифры? InitGraph(dr, md, ' '); // Не нужно в dr и md что-то записать перед вызовом? for i := 1 to ElementsCount do begin SetColor(i); str(p[i], pr); OutTextXY(100+80*(i-1), 430, pr); str(i, par); OutTextXY(100+80*(i-1), 440, par); ReadLn; // нужно будет жать `ввод` после вывода каждого элемента end; END.