How to print the ASCII value of a character?1 week ago

ASCII abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices.

The below C program accepts a character and prints the ASCII value of the same character as the output.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;
    scanf("%c", &ch);
    printf("%d", ch);
    return 0;
}

The below Java program accepts a character and prints the ASCII value of the same character as the output.

import java.util.*;

public class Hello {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char ch = scanner.next().charAt(0);
        System.out.println((int) ch);
    }
}

The below Python program accepts a character and prints the ASCII value of the same character as the output.

char = input()
print(ord(char))