DEV Community

Snehal Rajeev Moon
Snehal Rajeev Moon

Posted on

5 2 1 1 1

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.. 🦄 ❤️

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay