2.History of programming language, an introduction

jamilurahmanfaizi 1 views 33 slides Sep 09, 2025
Slide 1
Slide 1 of 33
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33

About This Presentation

This slide provide history and level of programming language in details.


Slide Content

10/14/20241

Language Translator

Language Translator
Translators are system programms, which translate programs written
in any high, or assembly language into 1’s and 0’s or machine language.
There are three types of language processors or translators
Assembler
Compiler
Interpreter
Program code
Language
translator
Machine code

Assembler
The software that translates assembly code into the computer’s
machine code is called assembler
A program written by a programmer in assembly language is called
source program
After this source code has been converted into object code
Language Translator

Complier
A compiler is a computer software that translates a whole program,
called the source code at once into machine code (object code)
Interpreter
An interpreter in another type of translator used for translating a
language program into machine code
It takes one statement of program and translates it into a machine
instruction which is immediately executed by computer
Language Translator

TRANSLATION PROCESS
Source Program / code
Target Program / code

Programs
•Source Program:
•The program we write in English langue using the editor is called Source
program.
•This program is given to the compiler for translation.
•Target Program:
•The program i.e. produced by the compiler after translating the source
program is called target program.
•This program is in binary form.

Variable ,keyword, constant, data type
Variable:
an entity that may change its value during program execution is
called variable.
Keyword:
are words that meaning is already defined to the language.
Constant:
an entity that cant be changed during program execution.
Data type:
are used to show the type of data .

Data Type
data type is used to
•Identify the type of a variablewhen the variable is declared
•Identify the type of the return valueof a function
•Identify the type of a parameterpassed to function

Data Type (continued)
When the compiler encounters a declaration for a variable, it sets up a
memory location for it
An operator used on a variable or variables is legal only if
The operator is defined in that programming language for a variable
of that type
The variable or variables involved with the operator are of the same
or compatible types

Classifications of Data Types
Built-in data types
Fundamental data types (int, char, double,
float, void,bool)
Programmer-defined data types
Structure
Union
Enumeration

Fundamental Data Types
void–used to denote the type with no values
int–used to denote an integer type
char–used to denote a character type
float, double–used to denote a floating point type
int *,float *,char*–used to denote a pointer
type, which is a memory address type
bool-boolean values (true,false)

Constant & Variable
A constantis an entity or value that does not change during the
execution of a program.
an entity that may vary during program execution is called a variable.
Variablenames are names given to locations in memory.
These locations can contain integer, real or character constants.

Rules for Constructing Identifiers in C
The first character in the variable name must be an alphabet(A-Z,a-z)
or underscore.
Capital letters A-Z, lowercase letters a-z, digits 0-9, and the
underscore character
First character must be a letter or underscore
There can be no embedded blanks
Keywords cannot be used as identifiers
Identifiers are case sensitive
No commas or blanks are allowed within a variable name.
No special symbol other than an underscore (as in gross_sal)
can be used in a variable name.
Identifiers refer to the names of data types,
constants, variables, and functions
Example:
si_int
m_hra
pop_e_89

C constants can be divided into two major categories
Primary Constant
Secondary Constant
These constants are further categorized as shown in below figure

Rules for constructing Integer Constants
An integer constant must have at least one digit
It must not have a decimal point
It can be either positive or negative
If no sign precedes an integer constant, it is assumed to be positive
No commas or blanks are allowed within an integer constant
The allowable range for integer constant is -32768 to 32767
Example: 25, +134, 0, -600

Rules for constructing Character Constants
A character constant is a single alphabet, a single digit or a single
special symbol enclosed within single quotes
The maximum length of a character constant can be 1 character
Example:
‘A’, ‘l’, ‘5’, ‘=’, ‘ ’, ‘.’

Definitions
Initialization
Declaration
Variable
Constant
Terminator
Data type
Assignment operator
Int a =4;

Simple C Program
/* A first C Program*/
#include <stdio.h>
void main()
{
printf("Hello World \n");
}

Preprocessor Directives
The first thing to be checked by the compiler.
Starts with ‘#’.
Tell the compiler about specific options that it needs to
be aware of during compilation.
There are a few compiler directives.
#include <stdio.h>
Tell the compiler to include the file stdio.hduring compilation
Anything in the header file is considered a part of the program

Simple C Program
Line 1: #include <stdio.h>
As part of compilation, the C compiler runs a program called
the C preprocessor.
The preprocessor is able to add and remove code from your
source file.
In this case, the directive #includetells the preprocessor to
include code from the file stdio.h.
This file contains declarations for functions that the program
needs to use. A declaration for the printffunction is in this file.

Simple C Program
Line 2: void main()
This statement declares the main function.
A C program can contain many functions but must always
have one main function.
A function is a self-contained module of code that can
accomplish some task.
The "void" specifies the return type of main. In this case,
nothing is returned to the operating system.

Simple C Program
Line 3: {
This opening bracket denotes the start of the program.

Simple C Program
Line 4: printf("Hello World From About\n");
Printfis a function from a standard C library that is used to print
strings to the standard output, normally your screen.
The compiler links code from these standard libraries to the code
you have written to produce the final executable.
The "\n"is a special format modifier that tells the printfto put
a line feed at the end of the line.
If there were another printfin this program, its string would
print on the next line.

Simple C Program
Line 5: }
This closing bracket denotes the end of the program.

Structure of a C program#include <stdio.h>
void main (void)
{
printf(“\nHello World\n”);
}
Preprocessor directive (header file)
Program statement#include <stdio.h>
#define VALUE 10
int global_var;
void main (void)
{
/* This is the beginning of the program */
int local_var;
local_var = 5;
global_var = local_var + VALUE;
printf (“Total sum is: %d\n”, global_var); // Print out the result
}

}Preprocessor directive
Global variable declaration
Comments
Local variable declaration
Variable definition

Comments
Explanations or annotations that are included in a
program for documentation and clarification purpose.
Completely ignored by the compiler during compilation
and have no effect on program execution.
Starts with ‘/*’ and ends with ‘*/’
Some compiler support comments starting with ‘//’

Statements
A specification of an action to be taken by the computer
as the program executes.
In the previous example, there are 2 lines following
variable declaration and variable definition that
terminate with semicolon ‘;’.
global_var = local_var + VALUE;
printf (“Total sum is: %d\n”, global_var);
Each line is a statement.

Basic Functions
A C program consists of one or more functions that contain
a group of statements which perform a specific task.
A C program must at least have one function: the function
main.
We can create our own function or use the functions that has
been created in the library, in which case we have to include
the appropriate header file (example: stdio.h).

In this section, we will learn a few functions that are pre-
defined in the header file stdio.h
These functions are:
printf()
scanf()
In addition to those functions, we will also learn about Format
Specifierand Escape Sequencewhich are used with printf()
and scanf().

printf()
Used to send data to the standard output (usually the
monitor) to be printed according to specific format.
The general form of printf( ) function is,
printf( “format string", <list of variables> ) ;
<format string> can contain,
%f for printing real values
%d for printing integer values
%c for printing character values
Control string is a combination of text, format specifier and
escape sequence.
Example:
printf(“Thank you”);
printf(“Total sum is: %d\n”, global_var);
%d is a format specifier
\n is an escape sequence

scanf()
Read data from the standard input device (usually keyboard) and
store it in a variable.
General format:
scanf(“Control string”, &variable);
The general format is pretty much the same as printf() except that
it passes the address of the variable (notice the &sign) instead of
the variable itself to the second function argument.
Example:
intage;
printf(“Enter your age: “);
scanf(“%d”, &age);

Summary
The three primary constants and variable types in C are
integer, floatand character.
A variablename can be of maximum 31 characters.
Do not use a keywordas a variablename.
An expressionmay contain any sequence of constants,
variables and operators.
Input/output in C can be achieved using scanf( ) and
printf( ) functions.
Tags