ADBRITE ads links
You are here: CodeIdol > C++ > C++: The Complete Reference > page: 35 36 37 38 39 40 41 42 43 44 45
Nonstructured
Structured
FORTRAN
Pascal
BASIC
Ada
COBOL
Java
C++
C
Modula-2
Structured languages tend to be modern. In fact, a mark of an old computer
language is that it is nonstructured. Today, few programmers would consider using a nonstructured language for serious, new programs.
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 beginning.
C's main structural component is the function--C's stand-alone subroutine. In
C, functions are the building blocks in which all program activity occurs. They let you define and code separately the separate tasks in a program, thus allowing your programs to be modular. After you have created a function, you can rely on it to work properly in various situations without creating side effects in other parts of the program. Being able to 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 through the use of
code blocks. A code block is a logically connected group of program statements that is treated as a unit. In C, you create a code block by placing a sequence of statements between opening and closing curly braces. In this example,
if (x < 10) {
printf("Too low, try again.\n");
scanf("%d", &x);
}
C h a p t e r 1 :
A n O v e r v i e w o f C
7
You are here: CodeIdol > C++ > C++: 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
.......
|
|