Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
C language IDE
C programs with output illustrate various programming concepts - operators, loops,
functions, single and double dimensional arrays, performing operations on strings, files,
pointers, etc. Download executable files and execute them without compiling the source
file. Code::Blocks IDE is used to write programs, most of these will work with GCC
and Dev C++ compilers. The first program prints "Hello World" on output device.
Rules in programming language
GENERAL PROGRAMMING RULES
A) Modern computers are very powerful, memory became relatively cheap, and modern
compilers automatically optimize code better than the average programmer.
So, saving memory or CPU time is no longer of prime importance: what is important is
creating programs that are easy to VALIDATE (check that the results are correct) and
MAINTAIN (change to suit different future needs).
B) The building units of program code, procedures and functions, should be made as
GENERAL (suitable for many similar applications) and FLEXIBLE (able to handle different
types of input and computing requirements) as possible.
This principle promotes CODE REUSABILITY (using parts of old programs in new ones),
and also helps improve coding since programs that don't rely on special assumptions tend
to be more reliable.
A subprogram call has a performance cost, so sometimes you don't partition the program
to many subprograms but just arrange it in well defined blocks, optimizing compilers does
such things automatically (procedure inlining).
2) Short comments explaining the algorithms used, variables' roles and computation
steps
5) A text file explaining how to compile, link, install and use the program (and/or a Make
file).
E) Programs should be portable. To achieve this goal you should:
The problem is that most compilers offer nice LANGUAGE EXTENSIONS, that
sometimes are quite tempting to use, and may even be included in future revisions of the
standard. However, if you use language extensions, your program might not compile on
other machines without some rewriting, and so might be less useful.
F) A program source is really just a text file; as such it can and should be as READABLE
and EASY TO EDIT as possible.
In the chapter on program layout we will try to set some FORTRAN guidelines and give
some useful references.
G) A program should not depend on assumptions about the correctness of user's input,
guesses about expected data etc, this is called DEFENSIVE PROGRAMMING.
Make your program check user's input and key computation results, if wrong, try to
recover - go back to the last trusted point, or just give a detailed message and abort the
program.
Features of C language
It is a robust language with rich set of built-in functions and operators that can be
used to write any complex program.
The C compiler combines the capabilities of an assembly language with features
of a high-level language.
Programs Written in C are efficient and fast. This is due to its variety of data type
and powerful operators.
It is many time faster than BASIC.
C is highly portable this means that programs once written can be run on another
machines with little or no modification.
Another important feature of C program, is its ability to extend itself.
A C program is basically a collection of functions that are supported by C library.
We can also create our own function and add it to C library.
C language is the most widely used language in operating systems and embedded
system development today.