ADBRITE ads links
You are here: CodeIdol > C++ > Borland C++ Builder: The Complete Reference > page: 35 36 37 38 39 40 41 42 43 44 45
7
THE
FOUNDATION
OF
C++
Structured languages are newer; nonstructured languages are older. Today, few
programmers would seriously consider a nonstructured language for new software development.
New versions of many older languages have attempted to add structured elements. BASIC is an example. However, the shortcomings of these languages can never be fully mitigated because they were not designed with structured features from the start.
The main structural component of C is the function--C's stand-alone subroutine.
In C, functions are the building blocks in which all program activity occurs. They allow the separate tasks in a program to be defined and coded separately, thus allowing your programs to be modular. After a function has been created, you can rely on it to work properly in various situations, without creating side effects in other parts of the program. The fact that you can create stand-alone functions is extremely critical in larger projects where one programmer's code must not accidentally affect another's.
Another way to structure and compartmentalize code in C is to use code blocks. A
code block is a logically connected group of program statements that is treated as a unit. In C a code block is created by placing a sequence of statements between opening and closing curly braces. In this example,
if(x < 10) {
printf("too low, try again");
reset_counter(-1);
}
the two statements after the if and between the curly braces are both executed if x is less than 10. These two statements together with the braces are a code block. They are a logical unit: one of the statements cannot execute without the other. Code blocks not only allow many algorithms to be implemented with clarity, elegance, and efficiency, but also help the programmer conceptualize the true nature of the routine.
A Programmer's Language
One might respond to the statement, "C is a programmer's language," with the question, "Aren't all programming languages for programmers?" The answer is an unqualified "No!" Consider the classic examples of nonprogrammers` languages, COBOL and BASIC. COBOL was designed to enable nonprogrammers to read and, presumably, understand a program. BASIC was created essentially to allow nonprogrammers to program a computer to solve relatively simple problems.
In contrast, C was created, influenced, and field-tested by real working programmers.
You are here: CodeIdol > C++ > Borland C++ Builder: The Complete Reference > page: 35 36 37 38 39 40 41 42 43 44 45
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|