
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Integer to ASCII Character in C/C++
In C or C++ the character values are stored as ASCII values. To convert int to ASCII we can add the ASCII of character ‘0’ with the integer. Let us see an example to convert int to ASCII values.
Example
#include<stdio.h> int intToAscii(int number) { return '0' + number; } main() { printf("The ASCII of 5 is %d\n", intToAscii(5)); printf("The ASCII of 8 is %d\n", intToAscii(8)); }
Output
The ASCII of 5 is 53 The ASCII of 8 is 56
Advertisements