Write a program to find ASCII values of a character

04 May 2022

Write a program to find ASCII values of a character


Description

Get an input character from the user and the give the ASCII value of the given input as the output.

Input

b

Output

98

Input

B

Output

66


C Program

#include <stdio.h>

int main()

{

  char c;

  printf("Enter a character: ");

  scanf("%c",&c);

  printf("The ASCII value of inserted character is %d",c);

  return 0;

}


C++ Program

#include <iostream>

using namespace std;

int main()

{

    char c;

cout<<"Enter a character: ";

cin>>c;

cout<<"The ASCII value of inserted character is "<<(int)c;

return 0;

}


Java Program

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.print("Enter a Character: ");

char c=sc.next().charAt(0);

int i = c;

System.out.println("The ASCII value of inserted character is "+i);

}

}


Python

c = input('Enter the character :')

value = ord(c)

print("The ASCII value of inserted character is ",value)

Related Articles

Ask Us Anything !