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.