C + + Primer Plus 5th cycle and Relational Expressions learning notes

Source: Internet
Author: User

C + + provides 3 loops: For loop, while loop, and do While loop. If the loop test condition is true or nonzero, the loop repeats a set of instructions: If the test condition is false or 0, the loop is ended. Both the For loop and the while loop are ingress conditional loops, which means that the program checks the test conditions before executing the statements in the loop body. A Do While loop is an exit condition loop, which means that it checks the condition after executing the statement in the loop body.
The syntax of each cycle requires that the loop body consist of a single statement. However, this statement can be a compound statement, or it can be a statement block (multiple statements enclosed in curly braces).
A relational expression compares two values and is often used as a cyclic test condition. A relational expression is formed by using one of 6 relational operators: <, <=, = =, >=, >, or! =. The result of a relational expression is a bool type with a value of true or false.
Many programs read text input or document-by-byte, and the IStream class provides a variety of ways to do this. If CH is a char variable, the following statement reads the next character in the input into C h:
CIN >> ch;
However, it ignores spaces, line breaks, and tabs. The following member function call reads the next character in the input (regardless of what the character is) and stores it in CH:
Cin.get (CH);
The member function calls Cin.get () to return the next input character----including spaces, line breaks, and tabs, so you can use it:
ch = cin.get ();
The Cin.get (char) member function call indicates that EOF has been reached by returning a bool value that is converted to false, whereas the cin.get () member function Withers by returning the EOF value to indicate that the reached eof,eof is defined in the file iostream.
Nested loops are loops in loops that are suitable for working with two-dimensional arrays.

C + + Primer Plus 5th cycle and Relational Expressions learning notes

Related Article

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.