Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
L Jeganathan
Lecture 01
do various things.
2 As human languages are too difficult for a computer to
understand in an unambiguous way, commands are usually
written in a language specially designed for the purpose.
P ROGRAMMING L ANGUAGES
C
omputers could only understand the sequence of 0s and 1s (0
refers no power and 1 refers power in the circuit ) So the
Programs should be converted into a sequence of binary
numbers understandable to the computers Central Processing
Unit.
T
here are two ways to communicate with a computer. We take
the help of devices called Interpreter or Compilers. We can
use either of these.
I NTERPRETER
An interpreter normally means a computer program that
executes, i.e. performs, instructions written in a
programming language.
With an interpreter, the language comes as an
environment, where you type in commands at a prompt
and the environment executes them for you.
If anything goes wrong, many interpreters will drop you into
a debugger to help you track down the problem.
The advantage of an interpreter is that you can see the
results of your commands immediately, and mistakes can
be corrected readily.
C OMPILER
A compiler is a computer program (or set of programs) that
transforms source code written in a programming language
(the source language) into another computer language (the
target language, often having a binary form known as
object code).
The necessity to transform source code is to create an
executable program
The name "compiler" is primarily used for programs that
translate source code from a high-level programming
language to a lower level language (e.g., assembly
language or machine code).
A program that translates from a low level language to a
higher level one is a decompiler.
A program that translates between high-level languages is
usually called a language translator, source to source
translator, or language converter
Introduction to computer programming and Problem solving - CSE
Introduction to Programming languages
RUNNING A C PROGRAM
E DITING
write a computer program with words and symbols that are
understandable to human beings. This is the edit part of
the development cycle. You type the program directly into a
window on the screen and save the resulting text as a
separate file.
This is often referred to as the source file.
The custom is that the text of a C program is stored in a file
with the extension .c for C programming language
M ODEL C P ROGRAM
# include <stdio.h>
int
main (void)
{
printf ("Hello, world!");
return 0;
}
C OMPILING
You cannot directly execute the source file. To run on any
computer system, the source file must be translated into
binary numbers understandable to the computers Central
Processing Unit.
This process produces an intermediate object file - with the
extension .obj, the .obj stands for Object.
L INKING
The first question that comes to most peoples minds is
Why is linking necessary? The main reason is that many
compiled languages come with library routines which can
be added to your program.
Theses routines are written by the manufacturer of the
compiler to perform a variety of tasks, from input/output to
complicated mathematical functions.
In the case of C the standard input and output functions
are contained in a library (stdio.h)
so even the most basic program will require a library
function. After linking the file extension is .exe which are
executable files.
E XECUTING A P ROGRAM
hello
hello world !
This loads the executable file into memory and causes the
CPU to begin executing the instructions contained within it.
./hello loads and runs the executable file hello located in
the current directory
item Thus the text editor produces .c source files, which go
to the compiler, which produces .obj object files, which go
to the linker, which produces .exe executable file. You can
then run exe files as you can other applications.