Complementary task for topic: 1

M Nemeth · 2023-08-29 15:21:04.601220'

Printf: char

Printf: char

Task: Print character belongs to an ASCII code:
Write a C program that declares and initializes an integer with value less than 255. Use the printf() to get the character belongs to the code!

Hint: The character is stored in the memory as a code, that code is the ascii code. Try to print the integer as character.

Solution
#include 

int main() {
   
    int asciiCode = 100; // Store the ASCII code of the character
    char character = asciiCode; 
    
    printf("The ASCII code of the character %c is %d.\n", character, asciiCode);
    
    return 0;
}


Explanation

< < previous    next > >