Elhuyar. Science and Technology
The C language that we will continue to explain in this issue and in the coming years has achieved a great diffusion in recent years, being essential for those who today we immerse ourselves in the world of computer science to know it. Through this series of articles with a practical approach based on examples, we present the basics of language, but some other high-level language (BASIC, PASCAL, FORTRAN, etc.) assuming that structured programming is known and encouraged, that is, the distribution of difficult programs in simpler or functional subprograms.
Next chapters:
Language C in 1972 D. It was created by Ritchie within the project that was developing the UNIX operating system in the Bell laboratories of AT T. Although it is originally a system-oriented language (since UNIX was the first programmed system in high-level language) and is also used in application programs, C's most common scope of application is programming for the development of standard packages and programs. Therefore, many editors, database systems, graphics and management packages are developed in C. This is due to:
On the other hand, if programmers do not act rigorously, programs can be very cryptic and uninterpretable. On the other hand, the compiler does not prove much.
Therefore, it is difficult to detect and correct errors (for the latter debugger programs help more and more).
As already indicated, this C language will be explained by examples that will be tested once translated by Microsoft C compiler. Before starting with the language, remember the phases that appear in figure 1: definition of the problem, design of the algorithm, edition of the source program, compilation, link and finally the test.
Although C is a simple language, remembering the above, it has a large library in which there are input/output procedures, arithmetic and graphic functions and many other routines. In addition, we will promote a distributed compilation that favors structured programming. When using this build type, the programmer will keep your library by saving your object module in it. Consequently, the compilation link scheme to consider is shown in Figure 2.
In language C the main program always starts with the word main ().
The interests of audiences and juveniles represent the beginning and the end of the body of a function and all body sentences end with the symbol. In Figure 3 we present a simple program that we will analyze below.
printout
and scanf are the standard library functions that direct output and input (parentheses limit parameters). Within them, %s string is the format and\n end of line indicator. Other formats such as %d decimal format, %c character, %f real format and %e scientific writing are supported.
main () /* first program */{[20]
is a sentence of eracence. It defines the name variable as a 20-character table. The data types and their corresponding communications are analyzed in the following number. The character pairs /* and */ delimit a suggestion or comment. Therefore, the person involved will not be compiled.
It should be noted that the compiler distinguishes between case sensitive and case sensitive, and for example, since the name and NAME are different variables, it is recommended to write all the code in lowercase, except the parameterized constants and the new data types, which are usually capitalized.
Once the program is edited, the following steps will be followed until the program is tested.
With Microsoft compiler on a PC:
$msc
program
$ program
Regarding the UNIX Operating System:
$
Program -o. Program c
$
Student Corner Here we will explain and comment on the questions and proposals of those who follow the course C. To participate write to Elhuyar. "C programming language"
Gipuzkoa |