Dark Horse programmer------C language Learning notes---C language data types

Source: Internet
Author: User

Dark Horse programmer------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

1.1 C Language data types

01 Integer Data

L Integer constant decimal number: starts with a non-0 digit. Octal: Starts with the number 0. Hex: Start with 0x or 0X

l integer variable int, long int, short int,

#include <stdio.h>intMain () {#definePI 3.14DoubleR; Doubleh; Doubles; //Prompt user to enter two number: radius r, High hprintf"Please enter a radius: Please enter High: \ n"); //accept data entered by the userscanf"%LF%LF",&r,&h); //Calculation Resultss =2*pi*r*h + pi*r*R; //Output Resultsprintf"the surface area of the cylinder is%f\n", s); return 0;}

02 Real-Data

l Real type constant decimal form: 0.12 0.55

Exponential form: 1.2e3 E is preceded by a number and the following exponent is an integer

* Real variable float, double, longdouble,

03-Character data

* Character constant: is a single character enclosed in single quotation marks. Like ' A ' ' 0 '

* Character variables: Character variables are used to store character constants.

* String constants: is a sequence of characters with a pair of double quotation marks, the escape character ' \ s ' as the end flag.

04 Enum Type: You can use an enumeration type when there are only a limited number of possible values for a variable.

05 pointer type: pointer type is a special type of data, stored values are interpreted as an address in memory

#include <stdio.h>intMain () {intI=0, j=0, x=Ten, y=Ten, z=Ten, t=Ten, B; floatf,f1,f2,f3; /*single-Mesh operation*/x= -x; Y= ++i; Y= j + +; printf ("x=%d,y=%d,z=%d\n", x, Y, z); printf ("i=%d,j=%d\n", i,j); /*Binocular Operation*/I= t%3; J= t/3; printf ("i=%d,j=%d\n", i,j); /*Type Conversions*/F=Ten; b=2; F1=1/b* -+Ten+F; F2=1.0/b* -+Ten+F; F3= (float)1/b* -+Ten+F; printf ("f1=%f,f2=%f,f3=%f\n", F1,F2,F3); 

Dark Horse programmer------C language Learning notes---C language data types

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.