PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Basic C Program

Program to find ASCII Value of a Character

Input - Output

Input
Enter a character : A

Output
ASCII value of A = 65

Algorithm

Step 1: START

Step 2: Enter a character as input.

Step 3: Print ASCII value of the character

Step 5: END

CODE


/* ASCII value of a character*/

#include  <stdio.h>
int main()
{
      char ch;
      printf("Enter a character : ");
      scanf("%c",&ch);
      printf("ASCII value of %c = %d",ch,ch);
    return 0;
}


/* ASCII value of a character*/

#include  <iostream>
using namespace std;
int main()
{
      char ch;
      cout<<"Enter a character : ";
      cin>>ch;
      cout<<"ASCII value of "<<ch<<" = "<<int(ch);
    return 0;
}

OutPut

Enter a character : A

ASCII value of A = 65