Summary of classes on the second day of Camp David

Source: Internet
Author: User
Tags decimal to binary

Today, shange explained the conversion of hexadecimal and 32 keywords in C. Then I tried to calculate a conversion question.

 

Binary Conversion to decimal

1010 = 1*2 ^ 3 + 0*2 ^ 2 + 1*2 ^ 1 + 0*2 ^ 0 = 10

 

Decimal to binary

10 = 10/2 remainder 0

5/2 remainder 1

2/2 remainder 0

1/2 remainder 1

1 # include <stdio. h> 2 3 int main (INT argc, const char * argv []) 4 {5 int A = sizeof (INT); 6 printf ("A = % d \ n ", a); 7 8 char B = sizeof (char); 9 printf ("B = % d \ n", B); 10 11 long c = sizeof (long ); 12 printf ("c = % LD \ n", c); 13 14 float d = sizeof (float); 15 printf ("d = % F \ n", d ); 16 17 Double E = sizeof (double); 18 printf ("e = % lf \ n", e); 19 20 short F = sizeof (short ); 21 printf ("F = % d \ n", f); 22 23 int I, j; 24 int N = 4; // set the number of rows in the image to 25 26 for (I = 1; I <= N; I ++) // repeat the output of N rows to 27 {28 for (j = 1; j <= 2 * n-I; j ++) // repeat each character 29 If (j <= i-1) 30 printf (""); // output the leading space 31 else32 printf ("*"); // output the leading space * 33 34 printf ("\ n "); 35} 36 37 float G = 2.3; 38 printf ("G = %. 4f \ n ", g); 39 40 return 0; 41}

Output result:

A = 4
B = 1
C = 8
D = 4.000000
E = 8.000000
F = 2
*******
*****
***
*
G = 2.3000
Program ended with exit code: 0

 

Summary of classes on the second day of Camp David

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.