how to program
Statements on the same line

Lesson 05: Multiple statements can go on the same line, as in...

Program Code:

With a lot of programming languages, the white space between statements (white space includes normal spacebar characters, tabs, line breaks, etc) are ignored, so it it really up to the programmer what spacing is used. This is especially the case with C-like languages (e.g. C, C++, C#, Java, JavaScript, PHP, etc) which use semicolons ; to separate statements, but it is less the case with other languages (e.g. VB, VB.NET, etc) which use line breaks to imply special meaning within the code.

White space can also go within parts of statements, for instance there are spaces between the ( and the " in the env.out( "Hello World" ) statement

Multiple statements per line may or may not help with program clarity, and in most cases one major statement per line is preferred. This can also help with debugging.


1. Add spaces between the statements to see that it does not affect how the program is run.
2. Take out some spaces.
3. Does the code read better with statements on one line or on different lines? Add line breaks between the statements by placing the cursor in the appropriate place and pressing enter (return).

To return to previous page click here

Fri 18 Jun 2021 web design | login © 2021 Abstract Worlds Ltd