Soo...I have a question. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Soo...I have a question.

bmk12345bmk12345 Posts: 7Member
Is it possible to transfer data from an array of integers to a regular integer variable in a specific order?

EX: Say you have an array with numbers 1 2 3 4 5 in each memory slot. I would want to transfer those numbers to a variable, which would have the value of 12,345.

Thank you.

Comments

  • GrieverGriever Posts: 3Member
    I think you need to use the STR function. I think thats the one, but I haven't used it in a while.
  • bmk12345bmk12345 Posts: 7Member
    : I think you need to use the STR function. I think thats the one, but I haven't used it in a while.
    :
    Could you explain that to me?
  • GrieverGriever Posts: 3Member
    well, let me look things over. I'll get back to you later tonight. What version of Pascal are you using.
  • ibyiby Posts: 323Member
    [b][red]This message was edited by iby at 2003-4-1 17:46:32[/red][/b][hr]
    [code]
    var arr:array[1..5] of integer;
    i:integer;
    result:integer;

    begin

    {populate array}
    for i:=1 to 5 do arr[i]:=i;


    {put first array element into result}
    result:=arr[1];

    {combine remining array elements into result}
    for i:=2 to 5 do result=result*10+arr[i];

    {display result}
    writeln('Result is :',result);
    writeln('Press Enter to exit program...');
    readln;
    end.
    [/code]

    hope this helps...
Sign In or Register to comment.