Learn point C language (13): Data type

Source: Internet
Author: User
Tags include printf

整型int可添加short和long:
short int:简为short;
long int: 简为long;
long long int: 简为long long

它们都可以再添加 unsigned:
unsigned int:      简为unsigned
unsigned short int:   简为unsigned short
unsigned long int:   简为unsigned long
unsigned long long int: 简为unsigned long long

char 可添加 unsigned:
unsigned char

double 可添加 long:
long double

1. Minimum, maximum value of short:

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

int main(void)
{
  short n1 = SHRT_MIN;
  short n2 = SHRT_MAX;
  printf("%d .. %d\n", n1,n2);
  getchar();
  return 0;
}

2. The minimum and maximum value of a long:

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

int main(void)
{
  long n1 = LONG_MIN;
  long n2 = LONG_MAX;
  printf("%ld .. %ld\n", n1,n2);
  getchar();
  return 0;
}

3 The minimum, maximum value of long long:

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

int main(void)
{
  long long n1 = LLONG_MIN;
  long long n2 = LLONG_MAX;
  printf("%lld .. %lld\n", n1,n2);
  getchar();
  return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.