🔄Beginner

Int to Char Conversion

Convert integer to character

Convert integer to character (single digit or ASCII).

Program Code

int_to_char.c
C
1#include <stdio.h>
2
3int main() {
4 // Single digit to character
5 int digit = 5;
6 char ch = digit + '0'; // '0' has ASCII 48
7 printf("Digit %d as char: '%c'\n", digit, ch);
8
9 // ASCII value to character
10 int ascii = 65; // 'A'
11 char letter = (char)ascii;
12 printf("ASCII %d as char: '%c'\n", ascii, letter);
13
14 // Multiple digits to string
15 int num = 123;
16 char str[10];
17 sprintf(str, "%d", num);
18 printf("Number %d as string: \"%s\"\n", num, str);
19
20 return 0;
21}
Output

Digit 5 as char: '5'

ASCII 65 as char: 'A'

Number 123 as string: "123"

Want to Learn More?

Explore our comprehensive tutorials for in-depth explanations of C programming concepts.

Browse Tutorials
Back to All Examples