Convert long to short int : Long « Data Type « C / ANSI-C






Convert long to short int

  
#include <stdio.h>

int main(void)
{
  short int si;
  long int li;

  li = 100000;
  si = li; /* convert long to short int */

  printf("%hd", si);

  return 0;
}


           
       








Related examples in the same category

1.long value array
2.Summing integers - compact version
3.Choosing the correct type: longChoosing the correct type: long
4.Use nested if to analyze numbers
5.Read long from keyboard