C + + Basic tutorials-common data types

Source: Internet
Author: User

First, common data types

The program can handle a variety of data, we provide data to the program, and then get the expected results, let's look at an exercise;

1, start Geany

1 point Menu "application-programming-geany" Start Geany, create a new C + + source program;

2 Point Menu "file-Save as" command, to "Shuju" as the filename, save the file to its own folder;

2, input program code

1 in the Blue Code area below, enter a line "cout << 18;" (read as C-out, the final semicolon do not leak);

#include <iostream>

using namespace Std;

int main (int argc, char** argv)

{

cout << 18;

return 0;

}

2 save, compile, build, run will display a number 18, this is the numerical data;

3 Closes the return to the program window, presses the ENTER key in front of the cout, inserts a row,

Enter a line "cout <<" 2*9= ";" The semicolon does not leak;

cout << "2*9=";

cout << 18;

4 save, compile, build, run, this time with a double quotation mark is called string data;

5 then click the ENTER key before 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 quotes in front of this line are strings, followed by numeric addition operations,

The next line of Endl is a carriage return line feed, if not added to the next line together;

7 save, compile, build and run, now shows two lines;

8 Here is required to remember: The double quotes are strings, which can have letters, numbers, symbols, and 0~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.