Pejman Moghadam / C-programming

C - char data type

Public domain


#include <stdio.h>
#include <limits.h>

int main()
{
        char ch;

        ch='a';
        fprintf(stdout, "This is a single character: %c\n", ch);
        fprintf(stdout, "ASCII code of '%c' is : %d\n", ch, ch);
        fprintf(stdout, "Number of bits in a 'char' type : %d\n", CHAR_BIT);
        fprintf(stdout, "Minimum and maximum values a 'signed char' can hold : %d %d \n",
                                                                   SCHAR_MIN, SCHAR_MAX);
        fprintf(stdout, "Minimum and maximum values an 'unsigned char' can hold : 0 %d \n",
                                                                                UCHAR_MAX);
        return 0;
}

--Output--

This is a single character: a
ASCII code of 'a' is : 97
Number of bits in a 'char' type : 8
Minimum and maximum values a 'signed char' can hold : -128 127
Minimum and maximum values an 'unsigned char' can hold : 0 255

BY: Pejman Moghadam
TAG: c, data-type
DATE: 2011-02-28 15:31:00


Pejman Moghadam / C-programming [ TXT ]