Minggu, Juni 15, 2014

Define Value of Char Integer Variable On C Programming

As well as short int, int, dan long int integer variable, integer variable char also availabe typed signed and unsigned. Char variable tyoed signed begin from -128 up to 127 with printf code %d, while variable typed unsigned begin from 0 s/d 255 with printf code %u, where if they are defined out of value range will show false value when program is run

Example of program of define long int integer variable typed signed:

main()
{
  signed char var_integer_char_signed_minimum;
  signed char var_integer_char_signed_maximum;
  var_integer_char_signed_minimum = -128;
  var_integer_char_signed_maximum = 127;
  printf("%d\n", var_integer_char_signed_minimum);
  printf("%d", var_integer_char_signed_maximum);
  getch();
}


Example program of define value of char integer variable typed unsigned:

main()
{
  unsigned char var_integer_char_unsigned_minimum;
  unsigned char var_integer_char_unsigned_maximum;
  var_integer_char_unsigned_minimum = 0;
  var_integer_char_unsigned_maximum = 255;
  printf("%u\n", var_integer_char_unsigned_minimum);
  printf("%u", var_integer_char_unsigned_maximum);
  getch();
}



0 komentar: