You are on page 1of 61

Lecture No.

1
Engr. Murad Habib
Assistant Professor/
Project Director
University of the Punjab
An Engineer and Computers
Engineers use computers extensively
to produce and analyze designs;
to simulate and test how a machine, structure, or
system operates;
to generate specifications for parts;
to monitor the quality of products; and
to control the efficiency of processes
Study some useful definitions
A Materials Engineer

A Materials Engineer a
man who looks for
connections between the
underlying structure of a
material, its properties, how
processing changes it, and
what the material can do its
performance.

3
Metallurgy

Metallurgy the study of


metals and their alloys,
including their extraction,
microstructure and
processing.

4
The MTM triangle
A logical relationship between processing, structure and properties,
and guarantee of success in new material development

Structure

Properties
Processing
Semiconductors

Micro-Electrical-
Mechanical Systems
(MEMS)

Si wafer for computer


chip devices.

6
The Computer
A computer is a
machine that
manipulates data
according to
a set of instructions.

The first computers


were developed in
19401945,
they were very large in
size!

Modern computers are


based on integrated
circuits
making them very fast
and small in size.
Computers
A computer is an electronic machine that has the capability
to perform certain types of processing/computation on the
supplied data. It can also store the data as well as generated
results.

Data & Instructions Processing/ Information/Results


Computation

Storage
Computers
Device that accepts input, process and stores data, and
gives output
Device that can execute specific set of instructions in a
well-defined manner
Smaller and thinner than a
dime, this tiny silicon chip
contains millions of
transistors that work
together
Parts of a Digital Computer

Process Units

CPU: Central Processing Unit

This coordinates the operation of computer system


and performs arithmetic logic operations.

Input unit CPU Output unit


Parts of a Digital Computer

Data is input from a keyboard(3) which is again stored in RAM(4).


The CPU operates on the program and data in RAM(5) and
outputs results to the HDD(6) as well as the monitor(7).

This is all controlled by the CPU requiring only basic


data flow instructions from the programmer.
Few Basics: Hardware
Computer Hardware
Electric, electronic, and mechanical devices

Computer Software
Programs and data in electronic form on a storage
medium
Program- Sequence of Instructions
Computer

Hardware Software

CPU Memory I/O Etc. Application System


Software Software
Input devices
Processor & Memory
Storage devices
Output devices
Few Basics: Input Devices
Mouse
Keyboard
Joystick
Light pen
Bar Code
Reader
Tablet
Camera
Microphone
HDD (Hard Disk Drive)

A hard disk drive is a device for storing and retrieving


digital information, primarily computer data.
It consists of one or more hard rotating discs coated with
magnetic material, with magnetic head arranged to write
data to the surfaces and read it from them.
RAM (Random Access Memory)

Random-Access Memory (RAM)


RD-RAM
device allows stored data to be
accessed in very nearly the same
amount of time for any storage
location, so data can be accessed
quickly in any random order.

SDR-RAM DDR-RAM

DDR II-RAM

DDR III-RAM
Flash memory (memory cards, USB flash
drives), CD, DVD...

A USB flash drive is a data storage device that


includes flash memory with an integrated Universal
Serial Bus (USB) interface.

Secure Digital or (SD) is a non-volatile memory


card format for use in portable devices.

The Compact Disc, or CD for short, is an optical


disc used to store digital data.
Keyboard

A keyboard is a typewriter-style device, which uses an arrangement of


buttons or keys, to act as mechanical levers or electronic switches

Q- keyboard

F- keyboard
Mouse

A mouse is a pointing device that functions by detecting two-dimensional


motion relative to its supporting surface

Mechanical Optical Mouse Roller Mouse


Mouse
Touch screen/pad

A touchpad (or trackpad) is a pointing device featuring a sensor, a


specialized surface that can translate the motion and position of a user's
fingers to a relative position on screen.

Touchpad-
Touch Screen
Laptop
Monitor

A monitor or display (also called screen or visual display unit) is an


electronic visual display for computers.

CRT Monitor LCD-LED Monitor


Printer

A hardware device used to print "hard copies" of documents created or


stored on the computer.

Dot matrix, ink jet, bubble jet, and laser are some of the types of available
printers

Dot Matrix Ink Jet Laser


Speaker

A loudspeaker or speaker, is an electromechanical transducer which


converts an electrical signal into sound
Parts of a Digital Computer
Software

Software consists of programs loaded from storage units.


The programs execute on the computer hardware forming,
for example,

Operating System (OS)


Compilers
Application Programs

Operating System (OS)
The OS is a program written to interface
between the computer and its user. All
other software runs under the OS.

Examples are:

Miscrosoft Windows (XP,Vista, 7,8)


Linux (e.g. Redhat, Ubuntu, Pardus)
Mac OS X.
Compilers

Many programming languages require a


compiler to translate the statements of
program written in a high level language into
a low level language (machine code).

In this course we will use Dev C++ compiler


to obtain the executable forms of our
programs.

Ms.Visual Studio and Borland C++ can also


be used for compiling our C++ programs
Dev-C++
Bloodshed Software
http://www.bloodshed.net/dev/devcpp.html
Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB)
with Mingw/GCC 3.4.2

31
Dev-C++
New Source File

Compile
Run

32
Application Programs

These are (usually compiled)


programs written to perform a
specific task.

Examples are:

Microsoft Word
AutoCAD,
SolidWorks
Catia
34
Program
A precise sequence of steps to
solve a particular problem
Critical Skills
Analysis
Critical Thinking
Attention to Detail
Design Recipe
To design a program properly, we must:
Analyze a problem statement, typically
expressed as a word problem
Express its essence, abstractly and with
examples
Formulate statements and comments in a
precise language
Evaluate and revise the activities in light of
checks and tests
Area of the Ring
Inner Circle

Outer Circle

Area of Outer Circle____


Area of Inner Circle = Area of the Ring
Integrated Development Environment
(IDE)

It contains
Editor
Compilers
Debugger
Linkers
Loaders
Lifecycle of a C++ Program
xterm An IDE
window
console/terminal/window
Makefile WebCAT
make turnin/checkin E-mail
make utility
Runtime/utility
libraries
(binary) .lib .a .dll .so Eclipse
C++ Visual Studio
Programmer source code
(you) debugger

precompiler
gcc, etc. link
compiler linker executable
compiler program
object code
(binary, one per compilation unit) .o
Program is created in the
Editor Disk editor and stored on disk.
Preprocessor program
Preprocessor Disk processes the code.
Compiler creates
Compiler Disk object 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.
History of C and C++
History of C
Evolved from two other programming languages
BCPL and B
Typeless languages
Dennis Ritchie (Bell Laboratories)
Added data typing, other features
Development language of UNIX
Hardware independent
Portable programs
1989: ANSI standard
1990: ANSI and ISO standard published
ANSI/ISO 9899: 1990
42
History of C and C++
History of C++
Extension of C
Early 1980s: Bjarne Stroustrup (Bell Laboratories)
Spruces up C
Provides capabilities for object-oriented programming
Objects: reusable software components
Model items in real world
Object-oriented programs
Easy to understand, correct and modify
Hybrid language
C-like style
Object-oriented style
Both

43
The C Programming Language
Developed by Dennis Ritchie at AT&T Bell Laboratories
in the early 1970s
Growth of C tightly coupled with growth of Unix: Unix
was written mostly in C
Success of PCs: need of porting C on MS-DOS
Many providers of C compilers for many different
platforms => need for standardization of the C language
1990: ANSI C (American National Standards Institute)
International Standard Organization: ISO/IEC 9899:1990
1999: standard updated: C99, or ISO/IEC 9899:1999
General Program Structure
preprocessing directives
int main()
{
declarations;
statements;
}

45
#include <iostream>
main ( )
{
cout << Welcome to University ;
}
A Very Simple C++ Program

#include <iostream> // precompiler directive

using namespace std; // compiler directive

// definition of function named main


int main ()
{
cout << hello, world! << endl;
return 0;
}
48
What is a stream?
Flow of characters (or other data)
Input
Characters that come IN to your program
Output
Characters that come OUT of your program
Input/Output (Sources/Sinks)
Input: Keyboard, File,
Output: Monitor, File,
Using iostream
Include iostream
Standard iostream objects:
cout - object providing a connection to the monitor
cin - object providing a connection to the keyboard
What is #include <iostream> ?
#include tells the precompiler to include a file
Usually, we include header files
Contain declarations of structs, classes, functions

<iostream> is the C++ label for a standard header


file for input and output streams
52
What is using namespace std; ?

The using directive tells the compiler to include code


from libraries that have separate namespaces
Similar idea to packages in other languages
C++ provides a namespace for its standard library
Called the standard namespace (written as std)
cout, cin, standard iostreams, and much more
using namespace std;
56
Whats cout << hello, world! << endl; ?

Uses the standard output iostream, named cout

<< is an operator for inserting into the stream


A member operator of the ostream class
Returns a reference to stream on which its called
Can be applied repeatedly to references left-to-right

hello, world! is a C-style string


A 14-postion character array terminated by \0

endl is an iostream manipulator


Ends the line, by inserting end-of-line character(s)
Also flushes the stream
58
What about return 0; ?

The main function should return an integer


By convention it should return 0 for success
And a non-zero value to indicate failure
Windows Friendly Exit
// Windows friendly exit
system("PAUSE");
return 0;

60

You might also like