C ++ basic tutorial-Common Data Types

Source: Internet
Author: User

I. Common Data Types

The program can process various types of data. We provide the program with data and get the expected results. Let's take a look at the exercises;

1. Start Geany

1) Click "Application-programming-Geany" in the menu to start Geany and create a c ++ source program;

2) Click the "file-save as" command in the menu and save the file to your folder with "shuju" as the file name;

2. Enter the program code.

1) in the following blue code area, enter a line "cout <18;" (read as c-out, and the last semicolon should not be missed );

# Include <iostream>

Using namespace std;

Int main (int argc, char ** argv)

{

Cout <18;

Return 0;

}

2) Save, compile, generate, and run the command to display a number 18, which is the numerical data;

3) Close the return to the program window, press the Enter key in front of the cout, insert a row,

Enter a line "cout <" 2*9 =;

Cout <"2*9 = ";

Cout <18;

4) Save, compile, generate, and run. This time, double quotation marks are added to the string data;

5) press the Enter key in front of the first cout, insert a blank line, and enter "cout <" 9 + 9 = "<9 + 9 <endl ;";

Cout <"9 + 9 =" <9 + 9;

Cout <endl;

6) The double quotation marks at the beginning of this line are strings, followed by the number addition operation,

The endl of the next line is the line break of the carriage return. If it is not added, it will be connected to the next line;

7) Save, compile, and run after generation. Now two lines are displayed;

8) Remember that double quotation marks are strings that can contain letters, numbers, and symbols, while ~ 9 is composed of numbers;

# Include <iostream>

Using namespace std;

Int main (int argc, char ** argv)

{

Cout <"9 + 9 =" <9 + 9;

Cout <endl;

Cout <"2*9 = ";

Cout <18;

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.