Answers for "how to ascii value in c"

C
2

print ascii value in c

#include <stdio.h>
int main() {  
    char c;
    printf("Enter a character: ");
    scanf("%c", &c);  
    
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    
    return 0;
}
Posted by: Guest on June-04-2021
0

how to transform a char to ascii code in c

int a_as_int = (int) 'a';
Posted by: Guest on June-22-2020
0

char ASCII in c

#include <stdio.h>
int main()
{
/*
When a character is entered by the user in the above program, 
the character itself is not stored. Instead, an integer value (ASCII value) is stored.

And when we display that value using %c text format, 
the entered character is displayed. If we use %d to display the character,
it's ASCII value is printed.
*/
    char chr;
    printf("Enter a character: ");
    scanf("%c",&chr);  
    printf(" char in  ASCII value %d.", chr); 
    printf("You entered %c.", chr);  
    return 0;
}
Posted by: Guest on March-01-2022

Code answers related to "how to ascii value in c"

Code answers related to "C"

Browse Popular Code Answers by Language