Program to find ASCII values of a character

Program to find ASCII values of a character

09 May 2023

09 May 2023

Write a program to find ASCII values of a character



Description about Program to find ASCII values of a character

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 to find ASCII values of a character

#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 to find ASCII values of a character

#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 to find ASCII values of a character

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 Program to find ASCII values of a character

c = input('Enter the character :')

value = ord(c)

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



Related Articles

Ask Us Anything !