4 Computer-Programming-CS101.ppt
-
Upload
muhammad-abuzar-khan -
Category
Documents
-
view
214 -
download
0
Transcript of 4 Computer-Programming-CS101.ppt
-
7/25/2019 4 Computer-Programming-CS101.ppt
1/12
CS101: Introduction to Computing
Instructors:Dr. Fawad Hussain, Dr. Rashad Jilani, Engr.
Ahmad Sohaib, Engr. Zawar Hussain, Engr.Usman Raa ! Dr. Ahmar Rashid.
Facult" o# $om%ut&r Sci&nc& andEngin&&ring
'I( Institut& o# Engin&&ring Sci&nc&s and
)&chnolog"
Fall 2015
-
7/25/2019 4 Computer-Programming-CS101.ppt
2/12
ComputerProgramming
-
7/25/2019 4 Computer-Programming-CS101.ppt
3/12
Computer Programming
$om%ut&r %rogramming is th& %roc&ss o#
writing instructionsthat dir&ct a com%ut&r to
carr" out s%&ci#ic tas*s
A computer program is a s&t o# step-by-
step instructions that t&ll a com%ut&r how to
sol+& a %robl&m or carr" out a tas* )h& instructions that ma*& u% a com%ut&r %rogramar& o#t&n r&rr&d to as code
A %rogram is writt&n in a com%ut&rprogramming
language
-
7/25/2019 4 Computer-Programming-CS101.ppt
4/12
Programming Languages (-1-)
Aprogramming languageis an artificial
languaged&sign&d #or cr&ating instructions that a
com%ut&r can carr" out
In contrast, th& languag&s w& s%&a* &.g., English - Urdu ar&natural languages
/rogramming languag&s di##&r #rom natural
languagesin that natural languag&s ar& us&d #or int&raction b&tw&&n %&o%l&
%rogramming languag&s allow humans to communicat&
instructions to machin&s as w&ll as machin&0to0machin&
int&raction
-
7/25/2019 4 Computer-Programming-CS101.ppt
5/12
Programming Languages (-2-)
/rogramming languag&s can b& di+id&d into two ma1or
cat&gori&s
2ow0l&+&l languag&s
R&3uir& th& %rogramm&r to writ& instructions #or th& low&st l&+&l o#com%ut&r4s hardwar& Eas" #or com%ut&r to und&rstand5 Di##icult #or humans
E6am%l&s: Machine Language, Assembly Language
High0l&+&l languag&s 7a*&s %rogramming %roc&ss &asi&r b" %ro+iding commands such
as /RI8) or 9RI)E inst&ad o# unint&lligibl& strings o# s and ;s
E6am%l&s: FORTRAN, C, C++, Java, Pythn !
2anguag&s can also b& cat&gori&d b" g&n&rations
-
7/25/2019 4 Computer-Programming-CS101.ppt
6/12
LO-L!"!L
L#$%%!S
Programming Language
Categori'ation
#*#!
+#CI$! L#$%%!
#SS!+,L
L#$%%!
I%-L!"!L
L#$%%!S
1st%eneration
Language .1%L/
2%L
%L %L
-
7/25/2019 4 Computer-Programming-CS101.ppt
7/12
+ac3ine Language 4
+ac3ine Code
)h& #irst languag&s #or %rogramming com%ut&rs < smetimes
referre" t as first-generation languages
A machin& languag& consists o# a s&t o# commands,
r&%r&s&nt&d as a series of 1s and 0s, corr&s%onding to th&
instruction set und&rstood b" a micro%roc&ssor
A machin& languag& is s%&ci#ic to a %articular $/U or
micro%roc&ssor #amil"
High0l&+&l languag&s ar& =mostl"> translatedcm#ile"to
machin& languag& in ord&r to b& und&rstood and &6&cut&d b"
th& micro%roc&ssor
-
7/25/2019 4 Computer-Programming-CS101.ppt
8/12
!ample
#dd t3e registers 1and 26 Place t3e result in
register 76 o% ? rs ? rt ? rd ? shamt ? #unct
; @ ; B@ decimal
;;;;;; ;;;; ;;;; ;;; ;;;;; ;;;;;
8inar9
+ac3ine Language 4
+ac3ine Code
-
7/25/2019 4 Computer-Programming-CS101.ppt
9/12
#ssem8l9 Language
Allows %rogramm&rs to us& abbr&+iat&d
command words rath&r than s and ;s us&d in
machin& languag&sA signi#icant im%ro+&m&nt o+&r machin& languag&s
7n&monics such as ADD, SUC, 7U2, DI, J7/ &tc ar&
mor& und&rstandabl& than ;;;, ;;; &tc
Also r&rr&d to as second-generation languagesAss&mbl" languag&s ar& also machin& s%&ci#ic
Each ass&mbl" languag& command corr&s%onds on a
on&0to0on& basis to a machin& languag& instruction
-
7/25/2019 4 Computer-Programming-CS101.ppt
10/12
#ssem8l9 Language
!ample 1
#dd 10 to t3e aria8le +#;S
ADD 7AR(S, ;
!ample 2
-
7/25/2019 4 Computer-Programming-CS101.ppt
11/12
ig3-leel languagesC4C>> ?#"# ,#SIC and etc6 Similar to &+&r"da" English,
Us& math&matical notations
!ample 1
Add 10to th& +ariabl& +#;S
7AR(S 7AR(S G ;5
!ample 2
Assign th& +alu& 10to th& +ariabl& #, +alu& 20to +ariabl& ,,addth&m and stor& th& r&sults in +ariabl& C
A ;5 C @;5
$ A G C5
-
7/25/2019 4 Computer-Programming-CS101.ppt
12/12
$et
8ow w& mo+& on to: $ How to /rogram