Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Soo...I have a question. Posted by bmk12345 on 1 Apr 2003 at 4:03 PM
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.
Report
Re: Soo...I have a question. Posted by Griever on 1 Apr 2003 at 4:34 PM
I think you need to use the STR function. I think thats the one, but I haven't used it in a while.
Report
Re: Soo...I have a question. Posted by bmk12345 on 1 Apr 2003 at 4:37 PM
: 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?
Report
Re: Soo...I have a question. Posted by Griever on 1 Apr 2003 at 4:52 PM
well, let me look things over. I'll get back to you later tonight. What version of Pascal are you using.
Report
Re: Soo...I have a question. Posted by iby on 1 Apr 2003 at 5:45 PM
This message was edited by iby at 2003-4-1 17:46:32

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.


hope this helps...



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.