Professional Documents
Culture Documents
Introduction To Programming
Introduction To Programming
Communication:
Means “sharing of information”
1. If both person understand each other its called
effective communication.
2. If one person understand English and other
understand Chinese then one of these have to learn
one of the language to understand each other.
3. If we want to command on Computer we have to
learn Computer language.
History of “C” Language:
1. Machine language
2. Assembly Language
3. FORTRAN
4. COBOL
5. CPL
6. BCPL
7. B
8. C
9. C++
10. Java
Machine Language:
It consists of 0,1
It is also called as pure binary language. Because it
only contains 100% 0,1.
It is also called as;
o LLL ( Low Level Language)
o MOL ( Machine Oriented Language)
It is difficult to understand, learn, write and debug.
A program written in machine language runs fast,
because computer understand 0,1 very easily.
A person who works in machine language is called as
SYSTEM EXPERT.
Assembly Language:
In assembly language 100% of machine language was
taken out of which 20% was converted into English
like symbols called as (Mnemonics).
Where as the remaining 80% was still 0,1.
A translator was used with assembly language which
was capable to convert the 20% Mnemonics into 0,1
form.
That translator was called as Assembler.
A program written in assembly language runs fast but
slow as compared to machine language due to
translator (Assembler).
FORTRAN:
Stands for FORmula TRANslation
It is such a language which is used in a field where we
need fast and accurate calculation.
FORTRAN is used in the following fields;
o Engineering
o Mathematics
o Statistics
o Chemistry
o Physics etc…….
COBOL:
Stands for COmmon Business Oriented Language.
It is such a language in which we can develop
software, which will solve our problems regarding
business.
It can be purely applied to business field.
CPL:
Stands for Combined Programming Language.
75 % portion of FORTRAN and 75% portion of
COBOL were combined with each other.
CPL:
And CPL was introduced.
But it was flopped due to it’s huge size.
BCPL:
Stands for Basic Combined Programming Language.
Basic and important features from FORTRAN and
some basic and important features from COBOL were
combined with each other.
And they introduced a new language called as BCPL.
It got flopped due to its limitation.
“B” Language:
Ken Thompson was researcher at A.T & T’s (American
Telephone & Telegraph’s) Bell Lab.
Ken Thompson wrote language.
Ken Thompson thought what should be the name of
my language.
From Bell he took the “B” and kept the name of
language “B” Language.
Telephone was discovered by “ Alexander Graham
Bell”.
“C” Language:
Denis Ritchie was researcher of AT & T’s Bell Lab.
Denis Ritchie took permission from Ken Thompson
and modified “B” language.
A new language was introduced.
He also thought what should be the name of my
language now.
From alphabetical series after “B” there comes “C”
and he kept the name of language as “C” language.
Denis Ritchie gave C-language to ANSI (American
National Standard Institution).
“C” Language:
ANSI registered C-language that it can work in every
field e.g. Engineering, Mathematics, Business etc…
Programmer at that time left other languages and
adopted C-language.
This language was introduced in 1972.
It is also called as fundamental language.
C-language consists of 90 to 95 % English.
A translator is used that converts that English into
machine understandable form.
“C” Language:
That translator is called as “Compiler”.
There are three categories of language.
o H.L.L ( High Level Language)
o M.L.L ( Middle Level Language)
o L.L.L (Low Level Language)
C-language has the feature of H.L.L and L.L.L, that’s
why also called as M.L.L.
“C” Language Character Set:
1. A… Z
2. a....z
3. #,_,+,-,<,>,=,!.........
Variable:
A named memory location, which holds something,
is called as variable.
Variable always get created inside “RAM”.
Variable Types:
There are three main types of variable;
Variable Types:
1. Integer variable (2 bytes): that space in memory,
which stores integer values is called as integer
variable e.g. (1,2,3.....)
2. Float | Real variable (4 bytes) : That space in
memory which stores float values, called as float
variable, e.g. (9.8, 88.12, 77.4……)
3. Character variable (1 byte): That space in memory,
which stores character values is called as character
variable e.g. (‘1’, ‘A’, ‘@’……..)
Constant:
“That thing, which get store inside variable, is called
as Constant”.
Constant Types:
There are three main types of Constant;
1. Integer Constant: (1,2,3,4,5,6………………..)
2. Float | Real Constant: (9.8, 8.12, 3.12……..)
3. Character Constant: (‘A’, ‘B’, ‘2’, ‘!’,……..)
Note: Any single character enclosed in single commas is
called character Constant, e.g. ‘A’ ‘1’, ‘@’. ‘9’……)
Data Type:
“These are reserved word, use to create or declare
variables of different types inside the memory”.
Data Type: Meaning:
int Stands for Integer, use to make
integer variable.
float Stands for Float, use to make float
variable.
char Stands for Character, use to make
character variable.
Data Type:
How to declare or create variable using Data Type;
Data Type: Variable Name:
int x;
float y;
char c;
Note: Compiler check each data and convert to
machine language, which only consist of 0,1.
Rules for Naming variable:
1. Variable name may consists of;
o Alphabets
o Numbers
o And a special symbol _ .
2. Variable name must start from an alphabet or _.
3. Reserved words can’t be the name of variable.
4. No spaces allowed in the name of variable.
C-Language Programming Structure:
main ()
{
Statement 1;
Statement 2;
Statement 3;
Statement n;
}
Starting for this (main ()) and Ending with } is called
main block.
This symbol ({) is called start of program and This
symbol (})is called end of program.
We will write the C-language program in the editor.
Save the file by any name have extension .c
File name length may not exceed from 8 characters.
File name may not have space inside it.
Output Function:
“If we want to print something over the screen, we will use
the following function;
printf(“Allah”);
main ()
{
clrscr();
printf(“text”);
}
File save by the any name e.g. (first.c).
Now we need to compile our program.
What happens when we compile program; File name.obj
1. Editor or
2. RAM 3. Output
Source code
main()
{
clrscr();
printf(“1st line”);
printf(2nd line”);
printf(3rd line”);
}
Note: when we compile it on the user screen it will come on
one line until that 80 columns finished so for break
through the normal sequence we use (escape sequence).
Escape Sequences: “These are special character,
preceded by \, and are used to break the normal
sequence of printing.”
Escape Sequence; Meaning;
\n Go to next line.
\t Go ahead 8 character (tab)
\a Alert (beep sound)
\” To print “
\’ To print ‘
\\ To print \
main()
{
clrscr();
printf(“\”1st lint\””);
printf(“\n\’2nd line\’”);
printf (“\n\\3rd line\\”);
printf(“\n\n\n\n\t\t\t\t\t\tK\aA\aR\aD\aA\aN);
}
Note: do it practical and check the difference of each
option.
Operators: “Operators are special symbols, on to which
the compiler performs a specific action, the action
performed depends, upon the nature of the operator
used.”
printf(“shafiq”);
gotoxy(1,24);
printf(“shafiq”);
gotoxy(74,24);
printf(“shafiq”);
shafiq shafiq
}