Introduction To Computers - Languages: Department of Computer Science & Engg. Sgi, Samalkha
Introduction To Computers - Languages: Department of Computer Science & Engg. Sgi, Samalkha
Introduction To Computers - Languages: Department of Computer Science & Engg. Sgi, Samalkha
SGI,SAMALKHA
Introduction to Computers
- Languages
Example:
1. Input unit
2. Output unit
3. Memory unit
4. Arithmetic and logic unit (ALU)
5. Central processing unit (CPU)
6. Secondary storage unit
Programming Languages
1. Machine languages (machine dependent)
Native tongue of a particular kind of computer. Each
instruction is a binary string. The code is used to indicate
the operations to be performed and the memory cells to be
addressed. This form is easiest form of computers to
understand, but is most difficult for a person to understand.
Strings of numbers giving machine specific instructions
Example: +1300042774
+1400593419
+1200274027
Programming Languages (cont.)
2. Assembly languages (machine dependent)
English-like abbreviations representing elementary computer
operations (translated via assemblers)
Again specific to only one type of computer. Uses descriptive
names for operations and data, e.g. , “LOAD value”, “ADD
delta”, “STORE value”. Assemblers will translate these to
machine languages. Intermediate level. Somewhat
descriptive, but basically following the machine instructions.
main()
{
int i;
for (i = 0; i ++; i < 10)
{
printf ("Hello World!\n");
}
}
A Typical C Program Development Environment
•Phases of C Programs:
1. Program is created in the 1. Edit
Editor Disk editor and stored on disk
Preprocessor Disk
2. Preprocessor program
processes the code
2. Preprocess
3. Compiler creates object
Compiler Disk
code and stores it on disk.
3. Compile
Linker Disk 4. Linker links the object
code with the 4. Link
Primary Memory libraries
5. Load
Loader
5. Loader puts program
in memory.
6. Execute
Disk
Primary Memory
CPU
6. CPU takes each instruction
and executes it, possibly
storing new data values as
the program executes
A Typical C Program Development Environment (cont.)
• Procedure to Prepare a C Program for Execution
Enter the program code and
save as a source (*.c) file using
Word Processor (editor)
Revised
Source (.c) source file Correct
Compiler attempts to Failure
file on disk syntax
translate the program
(Format: text) errors
into machine code
List of errors
Success
Input data
Results
Constructs in C Language
Type Declarations: ex: int, float,…
I/O: ex: printf(), scanf()
Arithmetic and Logical Operations: ex: +,-,*,/,%,>,<,==,…
Arrays, Pointers, Structures, Unions, …
Functions
Arguments & return values
Recursion
Control Mechanisms: ex: if, else, while, for,…
Characters & Strings: ex: strcat(), strcpy(), …
File Processing: ex: fopen(), fclose(), …
Pre-processor: ex: #define …
Misc.
bit operations, ...
Operation System (OS)
Responsibilities: Command-line
Interface
Graphical User
Interface (GUI)
Communicating with the computer user UNIX MacOS
Managing allocation of memory, of processor MS_DOS
VMS
Windows
X Windows
time, and of other resources for various tasks (linux and solaris)