FIB-ASCII Value
Convert a given ASCII value to its corresponding character
Understand the Problem
Problem Statement
The program must accept a positive integer N representing an ASCII value as the input. The program must print the character equivalent of the N as the output. Fill in the missing lines of code so that the program runs successfully.
Example:
Input: 65
Output: A
Constraints
- 1 ≤ N ≤ 127 (Standard ASCII range)
- N must be a positive integer
- The program should handle valid ASCII values only
Examples
65AASCII value 65 corresponds to the character 'A' in the ASCII table.
97aASCII value 97 corresponds to the character 'a' in the ASCII table.
32 (space character)ASCII value 32 corresponds to the space character in the ASCII table.
Solution
#include <stdio.h>
#include <stdlib.h>
int main()
{
int N;
scanf("%d", &N);
printf("%c", N);
return 0;
}C Solution Explanation:
The C solution uses standard input/output functions. We declare an integer variable N to store the ASCII value, use scanf with %d format specifier to read the integer from stdin, and then use printf with %c format specifier to convert the integer to its character representation and print it.