Preliminary understanding of C + + and simple operation introduction (i)

Source: Internet
Author: User

Because of the basis of C, found that C + + is not really difficult, I am here to record my study journey, yes, today, I formally started my C + + learning journey.

I think, before learning C + + will not be less learning input and output bar, for input and output, first contact is CIN and cout, found in fact very good remember, the first letter is C, input in, output is out;

For CIN and cout, here's what I should note:

For CIN:

(1) >> is an extraction operator used in conjunction with CIN, which skips a space before reading and then reads to a space.

(2) cin>>x>>y; This statement is from the keyboard input x and Y values, I think this input method compared to the Input method C, convenient is not 1:30 point.

(3) in the textbook found a very important place, the data input, the system in addition to check whether there is a blank, but also check whether the input data and type match, like (2) in the statement, if X is an int, y is a float type, if you enter 9.38 6.12 of these two numbers, Our idea is to assign 9.38 to X and assign 6.12 to Y, but that's not true, because x is int, so x has a value of 9, but Y's value is 0.38, which is something we need to pay attention to when we're on the program, and don't feel like the program is going to be a problem, actually.

For cout:

(1) cout I think the difference with printf is not very big, of course, in the wording or printf with the,<< can combine different data into a statement, you can also output the value of the expression, such as cout<<x+y<<z; This statement outputs the value of the x+y and Z values to the screen successively.

How to say,, feel cin and cout quite simple, a bit uncomfortable place is afraid to mix << and >>, but if the cooperation on the flow, it is not too difficult to remember.

There is, can not forget to use CIN and cout, the first to embed the header file iostream, plus namespace using namespace Std; This is easy to do.

Write the first C + + program, although know very simple, no error, but when the run successfully, still a little excited, haha.

Preliminary understanding of C + + and simple operation introduction (i)

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.