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

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging β†’

Top comments (0)

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay