How to find the ASCII value of a character in C

2 Answers

0 votes
#include <stdio.h>

int main(void) {
    char ch = 'a';
    
    printf("ASCII value of character %c is: %d", ch, ch);
}




/*
run:

ASCII value of character a is: 97

*/

 



answered Feb 13, 2021 by avibootz
0 votes
#include <stdio.h>

int main(void) {
    char ch = 'a';
    int ascii = (int)ch;

    printf("ASCII value of character %c is: %d", ch, ascii);
}




/*
run:

ASCII value of character a is: 97
 
*/

 



answered Dec 25, 2022 by avibootz

Related questions

2 answers 120 views
1 answer 150 views
1 answer 139 views
...