Arrays & Stringseasy
0 views

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

Example 1
Input
65
Output
A
Explanation

ASCII value 65 corresponds to the character 'A' in the ASCII table.

Example 2
Input
97
Output
a
Explanation

ASCII value 97 corresponds to the character 'a' in the ASCII table.

Example 3
Input
32
Output
 (space character)
Explanation

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;
}
Time:O(1)
Space:O(1)
Approach:

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.

Visual Explanation

Loading diagram...