C and Java are similar in process control

zhaozj2021-02-11  195

C and Java are similar in process control

Shandong Coal Education College Hu Zhenshan Guo Shiyi

Transfer programming (in representative language c) First must define the functionality to be implemented, then the next step must be required to realize these functions. This step is the process. The written code is actually equivalent to the solution to the steps, so that each step is directly connected to a line code. For real existing reuse, the code is set to the process or function. You can organize him to a process or function whenever you have a researched code. This kind of square is suitable for some questions, and the question is that the programs are more difficult, and the programs of the program will become very difficult. At this time, the programming (language) is not suitable. The programming method of facing the object and facing the object (representative Java) has become the main stream of the program. The root of the transcripts is in the case of the root of the root, is the inconsistency between him and the current model model. In the real world model, the physical body is the basic group of units, and the physical properties and behavior are, and both are sorry. In contrast, the language of the parallelism is concerned about the difference between the two. The first consideration of the main consideration is the need for those realities, and this actual body has a line. The body is the object, the line is the reflection of some messages. Process Control is critical to any programming language, and he provides the basic means of controlling program steps. It is the core part of the program. It can be said that the lack of control flows, there will be no programming language because Now there is no program that is just linearly executing the statement sequence. The order in the program is needed to communicate with the user, and it is necessary to use the user's input to determine the sequence, and there must be a loop execution, etc., these are less than the flow control. Java's flow control has: conditional statement if; cycle statement while, do while, for; switch statement Switch, case, break; transfer statement Break, continuR, label; return statement RETURN and complex statement. I don't know that this statement is in the case, there is no district. Yes, the statement is in the area, but it is still in the area. The condition statement If - ELSE condition statement is the most basic flow control statement in the programming language, and the condition statement of any one of the programs is used to use the IF keyword, because the condition statement is also called the IF statement.

Sentence statement, simple statement, and complex statement, such as the strip of the stroke, that is, the condition state statement, that is, called a composite condition statement, or nested condition statement; no, a simple statement. Usage: if (boolean) Statement1 else Statement2 is different: The conditions of the Java branch sentence must be a Bur type, and cannot be a numeric. This cannot be placed on the Numerical data like C, but should be replaced by the relationship table.

Class Sample1 {public static void main (string args []) {char ch; system.out.println ("please enter a number 1-3:"); ch = (char) system.in.read (); if CH == - 1) System.out.Println ("/ nno character entered."); Else IF (CH == '1') System.out.Println ("/ NYOU HAVE ENTERED A 1."); Else IF (CH == '2') System.out.Println ("/ NYOU HAVE ENTERED A 2."); ELSE IF (CH == '3') System.out.Println ("/ NYOU HAVE ENTERED A 3." ); Else System.Println ("/ NYOU HAVE ENTERED A WRONG NUMBER.");}} The loop statement repeatedly executed in a certain period in the execution. Java also provides three different loop statements. Cyclic statement while While The functionality of the statement is to repeat the sub-statement when the condition is established, and the number of repeated execution depends on the execution of the subforizons. The usage of the WHILE statement; the usement of the message;} loop, if you need a loop execution, at least Execute it, you can use the Do - WHILE statement. DO --- while statement is a variant of the While statement. Usage is: do {statements;} while (boolean_expression); the difference between Java and C cycle statements is mainly reflected in conditional expression The conditions of the C language are more flexible than Java, which can be any integer expression. Java must be a Boolean expression. Cycle statement for for statement is the most standard loop statement, almost Some advanced programming languages ​​provide a similar loop statement, and it is also the strongest loop structure. The functionality of the provoke is to loop execution of a statement until a condition is false, its structure is: for (Expresson1; Expression2 Expression3) {Statements;} class samplement2 {public static void main (string args [= 0; boolean test = true; while (test) {i = 1; system.out.println (" / NTHE LINE% D ", I"); if (i == 10) Test = false;} for (i = 20; i <= 30; i ) system.out.println ("/ nthe line% d", i ");}}} Switch statement SwitchSwitch is a variant of the conditional statement, its structure is: Switch (Expression) {CASE constant 1: statement 1; Break; Case constant 2: statement 1; Break; ....... ... default: statement 1;

转载请注明原文地址:https://www.9cbs.com/read-3543.html

New Post(0)