Learn point C language (12): Data type

Source: Internet
Author: User
Tags printf

C Language Data type: Basic type, constructed type, pointer type, empty type.

Basic types include: integer, character, floating-point (single, double), enumeration.

The constructed types also include: arrays, structs, and common bodies.

1. Display the minimum and maximum values of int:

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

int main(void)
{
  int n1,n2;

  n1 = INT_MIN;
  n2 = INT_MAX;
  printf("%d .. %d", n1,n2);

  getchar();
  return 0;
}

2. Display the minimum and maximum values for single precision type (float):

#include <stdio.h>
#include <float.h>

int main(void)
{
  float f1 = FLT_MIN;
  float f2 = FLT_MAX;

  printf("%e .. %e\n", f1,f2);

  getchar();
  return 0;
}

3. Display minimum and maximum values for double:

#include <stdio.h>
#include <float.h>

int main(void)
{
  double d1 = DBL_MIN;
  double d2 = DBL_MAX;

  printf("%e .. %e\n", d1,d2);

  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.