Computer Science, asked by ankitakumari1227, 11 days ago

write a program to which accept a character and displays it's ordinal value ​

Answers

Answered by Jha28utkarsh
1

Please try to mention the programming language whenever you want a program. I have written programs in some common programming language.

Python:

# Python program to print

# ASCII Value of Character

# In c we can assign different

# characters of which we want ASCII value

c = 'g'

# print the ASCII value of assigned character in c

print("The ASCII value of '" + c + "' is", ord(c))

C++:

#include <iostream>

using namespace std;

int main() {

char c;

cout << "Enter a character: ";

cin >> c;

cout << "ASCII Value of " << c << " is " << int(c);

return 0;

}

C:

// C program to print

// ASCII Value of Character

#include <stdio.h>

int main()

{

char c = 'k';

// %d displays the integer value of a character

// %c displays the actual character

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

return 0;

}

Java:

// Java program to print

// ASCII Value of Character

public class AsciiValue {

public static void main(String[] args)

{

 char c = 'e';

 int ascii = c;

 System.out.println("The ASCII value of " + c + " is: " + ascii);

}

}

C#:

// C# program to print

// ASCII Value of Character

using System;

public class AsciiValue

{

public static void Main()

{

 char c = 'e';

 int ascii = c;

 Console.Write("The ASCII value of " +

     c + " is: " + ascii);

}

}

Similar questions