FOR FREE CONTENT

ASCII value

Back to Programming

Description

ASCII stands for American Standard Code for Information Interchange.  It is a 7 bit character code in which a unique character is represented by every single bit. The ASCII value of ‘0’ is 48, ‘1’ is 49 and so on. The ASCII value of ‘A’ is 65, ‘B’ is 66 and so on. The ASCII value of ‘a’ is 97, ‘b’ is 98 and so on.

The program is written here to print the ASCII value of a character. For this, a character is taken as input and then the ASCII value of this character will be printed. For example, if the input is ‘a’ then the ASCII value of ‘a’ i.e. 97 will be printed.

Algorithm

INPUT: A character

OUTPUT: ASCII value of the given character.

PROCESS:

Step 1: [Taking the input]

               Read ch [the character]

Step 2: [Converting the character]

               Print ASCII value of ‘ch’.

Step 3: Stop.

Code

TIME COMPLEXITY:

The time complexity of this program is O(1) as it requires constant time to execute for any given input.

SPACE COPPLEXITY:

The space complexity of this program is O(1) as it requires a constant number of memory spaces to execute the program for any given input.