# Converting STRING to INTEGER/REAL....

I need to write a program that can find and print all the 3-digit palindromic prime numbers. Palindromic numbers are numbers that are the same forward and backword.

Since there is no pattern in these numbers, I'm just gonna test every number from 100 to 999 with a FOR-TO-DO loop. I need to test palindromes of each other.

So basically is there any way to give a variable a string value such as '343' and convert it to the integer, 343 or the real, 343.0?

Any help would be greatly appreciated.

• : I need to write a program that can find and print all the 3-digit palindromic prime numbers. Palindromic numbers are numbers that are the same forward and backword.
:
: Since there is no pattern in these numbers, I'm just gonna test every number from 100 to 999 with a FOR-TO-DO loop. I need to test palindromes of each other.
:
: So basically is there any way to give a variable a string value such as '343' and convert it to the integer, 343 or the real, 343.0?
:
: Any help would be greatly appreciated.
:
Use the Val() procedure for the conversion. More info in the help files.
• : I need to write a program that can find and print all the 3-digit palindromic prime numbers. Palindromic numbers are numbers that are the same forward and backword.
:
: Since there is no pattern in these numbers, I'm just gonna test every number from 100 to 999 with a FOR-TO-DO loop. I need to test palindromes of each other.
:
: So basically is there any way to give a variable a string value such as '343' and convert it to the integer, 343 or the real, 343.0?
:
: Any help would be greatly appreciated.
:[code][size=2]
:program palindrom;
:uses crt;
:var a:array[1..200]of string;
: k,inv,nr,i:longint;
:begin
: clrscr;
: k:=0;
: for i:=100 to 999 do
: begin
: nr:=i;
: inv:=0;
: while nr<>0 do
: begin
: inv:=inv*10 + nr mod 10;
: nr:=nr div 10;
: end;
: if (inv=i) then
: begin
: k:=k+1;
: str(i,a[k]); {str-function converts ordinal to string}
: {sintax : str(,) }:
:
: {val-function converts string to ordinal}
: {sintax : val(,
: ,}
: end;
: end;
:
:end.
[/size][/code]