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