DEV Community

Cover image for How to convert Character into integer and vice-versa?
stalin s
stalin s

Posted on

How to convert Character into integer and vice-versa?

ASCII code link: https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
//convert an integer into a character

int p = 54;
char x = (char)p;

//Convert character into an integer

char p ='a';
int x = (int) p;

include

using namespace std;

int main()
{
// integer to character conversion
int p = 43;
char x ;
x = (char)p;
cout<<x<<endl;
}

//the output of the following code would be '+'

include

using namespace std;

int main()
{
// integer to character conversion
char x = 56;
int p ;
p = (int)x;
cout<<p<<endl;
}

//the output of the following code would be 56

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay