Lecture No. 2 By. Mughal Yar M

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 31

Lecture No.

2
By.
Mughal Yar M
 What is programming
 Why programming is important
 What skills are needed
 Develop a basic recipe for writing programs
 Point to remember
 System Software

 Application Software
 Control the computer
 Communicate with computer’s hardware
(keyboard, mouse, modem, sound card)
 Sub categories of system software are
 Operating System (OS)
 Device Drivers
 Utilities
 A program or groups of program designed for
end users
 Accounting
 Payroll, Inventory Control System
 Banking Software
 ZABDEST
 HR System
 Shopping Systems
 GPS (Global Possitioning System)
 etc
 Developed in late 60’s and early 70’s in Bell
Laboratories.
 BCPL and B languages were developed there.
 BCPL language was developed in 1967 by
Martin Richards writing for OS and Compiler.
 In 1970 Ken Thompson used B language to
create early versions of the UNIX OS at Bell
Laboratories
 Both languages were being used to develop
various system software even compilers
 Dennis Ritchie developed a general purpose
language, called C language
 C uses many important concepts of BCPL and
B
 C is very powerful, even it compiler is written
in C language.
 You can program to turn OFF or ON any
device of computer
It contains
 Editor
 Compilers
 Debugger
 Linkers
 Loaders
Program is created in the
Editor Disk editor and stored on disk.
Preprocessor program
Preprocessor Disk processes the code.

Compiler creates object


Compiler Disk code and stores
it on disk.

Linker Disk Linker links the object


code with the libraries
Primary Memory
Loader
Loader puts program in
memory.
Disk ..
..
..

Primary Memory
CPU takes each
CPU instruction and executes
 
it, possibly storing new
data values as the
..
program executes.
..
..
#include <iostream.h>
main ( )
{
cout << “ Welcome to SZABIST-Karachi.“;
}
 #include
 Pre-processor directive
 Not part of our program
 Instruction to the compiler
 Compiler knows that it is system file.
 <iostream.h>
 Library definition file for all Input Output Stream
 main()
 Only one main() in program
 Run when your program is used.
 Cout<<“Welcome to SZABIST-Karachi.”;
 known as Output stream in C and C++
Variable X

During program need store data


Any type of data store in variables
Variables are location in memory
 Pic of the memory

 25

name
 10323 of the
variable
Variable starts with
1. Character
2. Underscore _ (Not Recommended)
 Small post box

X
Variable is the name of a location in
the memory

e.g. x= 2;
In a program a variable has:
1. Name

2. Type

3. Size

4. Value
=
x=2

X
2
L.H.S = R.H.S.

X+ 3 = y + 4 Wrong
Z = x +4
x +4 = Z Wrong
X = 10 ; X 10
X = 30 ;
X 30
X
10 + 1
= 11
X
 int i ; ->
Declaration line

i
#include <iostream.h>
main ( )
{
int x ;
int y ;
int z ;
x = 10 ;
y = 20 ;
z=x+y;
cout << " x = " ;
cout << x ;
cout << " y = " ;
cout << y ;
cout << " z =x + y = " ;
cout << z ;
}
int x, y, z ;
int x; int y; int z ;
1. int
2. short
3. long
4. float
5. double
6. char
Plus +

Minus -

Multiply *

Divide /

Modulus %
i+j
x*y
a/b
a%b
5%2=1
2%2=0
4/2=2
5/2=?
 Highest: ()
 Next: *,/,%
 Lowest: +,-

You might also like