DEV Community

Snehal Rajeev Moon
Snehal Rajeev Moon

Posted on

Print ANCII value of character

Hello Readers...

In this blog we will see how to find the ANCII value of given character using C and C++.

Program in C

#include <stdio.h>

int main()
{
   char character;
   printf("Enter character of your choice = ");
   scanf("%c", &character);
   printf("value of character is %c = %d", character, character);
}
Enter fullscreen mode Exit fullscreen mode

Output of above program

Image description

No let us see how to write a same program using C++

Program in C++

  #include <iostream>  
    using namespace std;  

    int main () {  
        char character;    
        cout<<"\n \n \t Enter any character = ";    
        cin>>character;
        cout<<"\t ANCII value of character " <<character << " = " << int(character);    
       return 0;  
    }  
Enter fullscreen mode Exit fullscreen mode

Output for above program
Image description

In this way we can find the ANCII value of given character using C and C++.

Thank you for reading.. 🦄 ❤️

Top comments (0)