xxxxxxxxxx
let num1 = 52;
let num2 = num1 + '';
console.log(typeof (num2))
//Expected outpur: string
xxxxxxxxxx
let x = 14;
document.getElementById("demo").innerHTML =
x.toString() + "<br>" +
(14).toString() + "<br>" +
(100 + 14).toString();
xxxxxxxxxx
# Convert integer to string
i = 23
s1 = int(i);
print ("string s1 =", s1);
# also
s2 = i.__str__();
print ("string s2 =", s2);
# and also
s3 = "{}".format(i);
print ("string s3 =", s3);
# another
print(f"as string {i} type {type(i)}" )
xxxxxxxxxx
String(x) // returns a string from a number variable x
String(123) // returns a string from a number literal 123
String(100 + 23) // returns a string from a number from an expression
xxxxxxxxxx
#include<stdio.h>
#include <math.h>
int main()
{
char str[80];
sprintf(str, "The value of PI = %f", M_PI);
puts(str);
return 0;
}