C language variable type and output control usage example Tutorial _c language

Source: Internet
Author: User

This article illustrates the C language variable type and output control usage, which is helpful for the reader to summarize and generalize it well. This example is shared for everyone to use for reference. Specifically as follows:

The full instance code is as follows:

/********************************************** * "Beginning C 4th Edition" Notes Codes * * Created by Goopand * * Compiler: GCC 4.7.0 ***********************************************/#include <stdio.h> int main (void) {*/* octal, hexadecimal integer representation     */int i1=024;    Octal number with number 0 opening int i2=0xf0;
  Hexadecimal begins with a 0x or 0X printf ("[output]\n");
  printf ("The decimal value of the octal number 024 is: \t%d\n", i1);
  
  printf ("Hexadecimal number 0xf0 decimal value is: \t%d\n", i2);
  /* Floating-point type representation and formatted output/double f1=1e1;
  Double f2=0.3e1;
  /*%-10.6LF indicates that the output length is 10 digits, the minus sign is left aligned, the%LF double-precision floating-point type output, and retains to 6 digits after the decimal point * printf ("\n[output]\n");   printf ("%.1f/%.1f =%-10.6lf|\n", f1,f2,f1/f2); Vertical line Character "|"
  Definition for marking the end position//constant/const FLOAT PI = 3.1415926535898f;
  printf ("\n[output]\n");
  
  printf ("Pi is:%.7f\n", pi);
  /* Study the return value of the printf () function/char c1= ' a ', c2= ' B ';
  printf ("\n[output]\n");
  printf ("Test the return value of the printf () function \ n"); printf ("%d\n", printf ("%d", printf ("%c%c", C1,C2)); The return value of the printf () function is the number of output characters/* character ASCII tables, including the escape character/char ch1=0;
 Initialized to null printf ("\n[output]\n"); printf ("Int and char ASCII-encoded correspondence \ n");
  printf ("\tint\tchar\n"); 
  printf ("\ t----\ t----\ n");
    for (int i=0;i<128;i++) {ch1=i;
  printf ("\t%d\t%c\n", i,ch1); 
return 0;

 }

Interested readers can test and run the example of this article, I believe there will be a new harvest.

Related Article

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.