<<

C Programming For Problem Solving

Course Code :18CPS13/23 Semester :I/II CIE Marks :40 SEE Marks : 60

Prepared By Muzammil Dakhani Department of Science Engineering

ZEROETH GENERATION

• Man used his fingers, ropes, beads, bones, pebbles and other objects for counting. • Abacus, Pascaline, Difference & Anylitical engines • Electricity was not yet invented FIRST GENERATION 1951 – 1958: The Vacuum Tube

• The first generation of , characterized by vacuum tubes, started in 1951 with the creation of - UNIVAC (Universal Automatic Computer) – a tabulating machine which won the contest for the fastest machine which could count the US 1890 census.

• The first computers used vacuum tubes for circuitry and magnetic drums for memory. • They were often enormous and taking up entire room. • First generation computers relied on machine language. • They were very expensive to operate and in addition to using a great deal of electricity, generated a lot of heat, which was often the cause of malfunctions.

The UNIVAC and ENIAC computers are examples of first- generation computing devices.

VACUUM TUBES – electronic tubes about the size of light bulbs. Second generation computers (1956-1963) : The Transistor

The year 1959 marked the invention of transistors, which characterized the second generation of computers.

TRANSISTOR – was a three-legged component which shrunk the size of the first generation computers. Occupied only 1/100th of the space occupied by a vacuum tube More reliable, had greater computational speed, required no warm-up time and consumed far less electricity.

• Transistors replaced vacuum tubes and ushered in the second generation of computers. • Second-generation computers moved from cryptic binary machine language to symbolic.

• High-level programming languages were also being developed at this time, such as early versions of COBOL and FORTRAN.

• These were also the first computers that stored their instructions in their memory.

THIRD GENERATION : The Integrated Circuit (1964-1971) Third generation computers arose in 1964 with the invention of smaller electronic circuits called integrated circuits (IC’S) INTEGRATED CIRCUITS – are square silicon chips containing circuitry that can perform the functions of hundreds of transistors.

• The development of the integrated circuit was the hallmark of the third generation of computers.

• Transistors were miniaturized and placed on siliconchips, called semiconductors. • Instead of punched cards and printouts, users interacted with third generation computers through keyboards and monitors and interfaced with an operating system.

• Allowed the device to run many different applications at one time. ADVANTAGES

• RELIABILITY – Unlike vacuum tubes, silicon will not break down easily. It is very seldom that you will have to replace it.

• LOW COST – Silicon chips are relatively cheap because of their small size and availability in the market. It also consumes less electricity.

Fourth generation computers (1971-present): The

• The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip.

• The Intel 4004 chip, developed in 1971, located all the components of the computer.

• From the and memory to input/output controls—on a single chip. • Fourth generation computers also saw the development of GUIs, the mouse and handheld devices.

• Marked by the use of microprocessor

• MICROPROCESSOR – is a silicon chip that contains the CPU – part of the computer where all processing takes place. 4004 chip – was the first microprocessor introduced by Intel Corporation.

Fifth generation computers (present and beyond) • is classified as fourth generation computers.

• faster, more powerful, tremendous storage and processing capacity

• new brands and models would come out the market almost every other month.

• many clones or imitations of the IBM have become even more powerful and a lot cheaper. • Fifth generation computing devices, based on artificial intelligence.

• Are still in development, though there are some applications, such as voice recognition.

• The use of parallel processing and superconductors is helping to make artificial intelligence a reality.

• The goal of fifth-generation computing is to develop devices that respond to natural language input and are capable of learning and self-organization. • computers became more affordable • computers can now be found in homes, schools, offices etc.

• there has been a tremendous improvement in software technology.

• different software applications to choose from: word processing, spreadsheets, database management, games and entertainment.

• computer subjects are now being offered not just to college students but even to high school and elementary.

• computers are now used as an aid in teaching math, science etc.

Types of Computers

• On the basis of configuration that is architecture, processing, power, size of main memory and other capabilities, computer can be divided in the following classes. • Super Computer • Mainframe Computer. • Mini Computer • Micro Computer. Super Computer

These are the • Largest. • Fastest. • Expensive. • Can handle over 10,000 users. • Parallel Processing. USE OF SUPERCOMPUTER • Super computers are used for solving complex application such as Global Weather Forecasting. Creating graphic images, engineering design and testing, space exploration and other problems where it is necessary to process huge quantities of data quickly.

• Cost: Several million dollars. • Speed: 60 billion instructions per second. • Size: Automobile Sized. Mainframe Computer

• Mainframe computer is usually slower, less Powerful and less expensive than super Computer.

• Mainframe computer can handle over hundreds of users . USE OF MAINFRAME COMPUTER • Mainframe Computer are useful for dealing with large over changing collection of data that are accessed by many users Simultaneously such as banks, airlines, railways. • Cost: Several hundred thousands dollars. • Speed: 250 million instructions per second. • Size: Refrigerator Sized. Mini Computer

• Mini computers are lower to mainframe computers in terms of speed and storage capacity. They are also less expensive than mainframe computers. Some of the features of mainframes will not be available in mini computers. Hence, their performance also will be less than that of mainframes. USE OF MINI COMPUTER

• Tele communications. • Cost: 25000 Dollars to Over 150,000 Dollars. • Speed: 150 million instruction per second • Size: Filling Cabinet size. Micro Computer

• The invention of microprocessor (single chip CPU) gave birth to the much cheaper micro computers. They are further classified into • Personal Computers • Computers • Handheld Computers(PDAs) Personal Computer

• They are usually easier to use and more affordable. They are normally intended for individual users for their word processing and other small application Requirements. • Desktop • Tower

What is a ?

• Bit is short for 'binary digit.' It's a single digit in a binary number, and it can be either 1 or 0.Inside a computer, you can think of a bit as being a mechanical switch, which can be either switched on or off. • Now if you only have one of these switches, you can only store two different states, on or off. This is useful in itself, you can record that something is either true or false... • But if you have, say, eight of them, you can store 256 different combinations of on and off states between the eight switches. What is a byte?

• A byte is 8 . That's the definition. With 8 bits you can store any number between 0 and 255, since there are 256 different combinations of 1 and 0 to choose from. • Why eight bits? The original intention was that, when storing text, 8 bits would be enough to assign a unique number every possible language character you might want to use in your document. The idea was that each character in a file would take up one byte of memory (in most cases, this is still true). • Let's see: there are 26 uppercase letters (A-Z), 26 lowercase (a-z), 10 numerical digits(0-9), 32 punctuation characters and other symbols on a US keyboard, the space character That's already 94 different characters. Then there's a few characters for creating newlines, a tab character for indentations, there's even a 'bell' character which programs would output in order to make the user's terminal beep. You can see how it all adds up What is a word?

• You often hear about 32-bit or 64-bit computer architectures. A word is basically the number of bits a particular computer's CPU can deal with in one go.

• It varies depending on the computer architecture you're using. Imagine looking at an imaginary computer's circuitry very closely. On a 32-bit machine, you would see 32 wires running parallel to each other between the computer's memory controller and the CPU, for the purpose of giving the CPU access to one particular word of memory.

• Actually, there would be an additional 32 wires (perhaps less) for the CPU to select a particular memory address to access. If a CPU can access 32 bits of memory in one go, then it turns out that it makes a lot of sense to address the computer's memory using ≤32 bits. (This happens to be why the 32-bit version of Windows can't deal with more than 2GB of RAM, but the 64-bit version can.) Bits ,Bytes and Words

Definitions • Bit = Binary digit = 0 or 1 • Byte = a sequence of 8 bits = 00000000, 00000001, ..., or 11111111 • Word = a sequence of N bits where N = 16, 32, 64 depending on the computer There are 2N words of length N. Why? How many bytes are there? Measuring Amount of Data/Memory Capacity

• 1 kilobyte = 1 KB = 210 bytes = 1024 bytes (appx 103 bytes) • 1 Megabyte = 1 MB = 220 bytes = 1,048,576 bytes (appx 106 bytes) • 1 Gigabyte = 1 GB = 230 bytes = 1,073,741,824 bytes (appx 109 bytes) CPU CPU

• Converts data into information • Control center • Set of electronic circuitry that executes stored program instructions • Two parts – Control Unit (CU) – (ALU) Control Unit CU • Part of the hardware that is in-charge

• Directs the computer system to execute stored program instructions

• Communicates with other parts of the hardware Arithmetic / Logic Unit ALU

Performs arithmetic operations Performs logical operations Arithmetic Operations

Addition Subtraction Multiplication Division Logical Operations

• Evaluates conditions • Makes comparisons • Can compare – Numbers – Letters – Special characters Registers

Special-purpose High-speed Temporary storage Located inside CPU

Data register Instruction register Holds data waiting to be Holds instruction currently processed being executed Holds results from processing Primary Storage: Memory

• Primary storage is directly accessible by the • Memory: – RAM = random access memory – ROM = read only memory – PROM/EPROM = programmable ROM • RAM is volatile (not retained w/o power) • cache, interrupts, memory, flags… Secondary: Mass Data Storage

• primary storage is directly accessible by the CPU (RAM, cache memory) • secondary storage is not directly accessed • data is transferred to primary memory when needed by processor • MDS is non-volatile - record and modify information (semi-)permanently Types of MDS

1. Punched surfaces - earliest method; human readable - punched cards, punched tape 2. Magnetic surfaces - most widely used - streaming tape, magnetic disks (floppy, hard, zip…) 3. Optical surfaces - most durable - optical disks (CD-ROM, laserdisc, DVD…) Comparisons of MDS types media: size/capacity: advantages: disadvantages:

Floppy 3.5” = 720KB, 1.44MB, 2.88 inexpensive; slow; 5 ¼” = 360, 720KB (old) shareable effected by 8” = 180, 360KB (old) magnetic fields, dirt, temp; corruptible Hard ¼, half & full height, fastest not usually 51/4”, 8” portable; = 5MB… 100+GB? not expandable Optical CD = 4.5” = massive capacity, read only 80-650MBdata/74minAudio high reliability, Laser = 8”,12” portability, DVD = 3.8 - 17GB data & audio standard

Removabl Clik = 25 - 40MB faster & more capacity slower than hard; Zip = 100-250MB than floppies; more expensive e Jaz = 500M - 2GB read/writeable than floppies SuperDisk (3M - Imation) =120MB Magneto- combination of technologies reliable; expensive; high capacity not as fast optical MO Flash solid state storage; no moving parts, very expensive; Memory memory sticks; flashcards rewritable no standard yet (newest) What are Ports?

• On computer, a port is • generally a specific place for being physically connected to some other device, usually with a socket or plug which we call Connectors

Typical Computer Port found behind a desktop PC What are Connectors?

• A connector is any connector used within computers or to connect computers to networks, printers or other devices.

Many types of computer connectors The PS/2 Connector

• The PS/2 connector are use for connecting keyboard and mouse on the modern PCs. The PS2 mouse connector and port is usually green in colour to distinguish it from the PS2 keyboard, which is purple. The USB Port

• Universal Serial Bus: a protocol for transferring data to and from digital devices. Many digital cameras and readers connect to the USB port on a computer. The Firewire IEEE 1394 Port

• A type of cabling technology for transferring data to and from digital devices at high speed. FireWire are typically faster than those that connect via USB. The RJ45 Port

• LAN or (Local Area Network) uses a CAT5 cable and a RJ45 connection. The CAT 5 cable is also called the Ethernet Cable.

• Network connection generally uses a 10/100 Mbps speed. This means it has two different speeds 10 Mbps and 100 Mbps. DB25

• The connects to your computer with a Parallel connector. This connector has 25 pins. • Parallel means the device is capable of receiving more than one bit at a time (that is, it receives several bits in parallel). Exploring Data Communications

Power connection

Keyboard port Mouse port

Audio connection

Monitor port FireWire port

USB ports Network port

Speaker and Phone line connections connection

Computer ports and connections 53 Input & output devices

• A computer system needs to communicate with its external environment its user). The Input/output devices provide this capability to a computer system. they are also known as devices, because they surround a computer's cpu and memory. ResultResult of of InputInput data data InputInput data data ProcessedProcessed processingprocessing fromfrom INPUTINPUT codedcoded into into CPUCPU && OUTPUTOUTPUT datadata in in inin human human externalexternal internalinternal DEVICESDEVICES DEVICEDEVICE memorymemory internalinternal for for acceptableacceptable worldworld formform formform • Input devices are used to enter data from outside world into primary storage & output devices supply the result of processing from primary storage to users. • Input device is any peripheral (piece of computer h/w equipment) used to provide data & control signals to an information processing system. Input/output devices make up the h/w interface between a computer . • The most common input devices are following. Keyboard , Mouse, Scanner, ,

• An output device is any piece of equipment used to communicate the results of data processing carried out by an information processing system (such as a computer) to the outside world. • In computing, input/output, or I/O, refers to the communication between an information processing system (such as a computer), and the outside world. • Inputs are the signals or data sent to the system, and outputs are the signals or data sent by t • Examples of output devices: Speaker , Headphones, Screen (Monitor), Printer, Projector etc…. Output devices Networking

A collection of computing devices that are connected in various ways in order to communicate and share resources Usually, the connections between computers in a network are made using physical wires or cables However, some connections are wireless, using radio waves or infrared signals

15-60 Networking

• The generic term node or host refers to any device on a network • Data transfer rate The speed with which data is moved from one place on a network to another • Data transfer rate is a key issue in computer networks

15-61 Networking

• Computer networks have opened up an entire frontier in the world of computing called the client/server model

15-62 Figure 15.1 Client/Server interaction Networking

• File server A computer that stores and manages files for multiple users on a network • Web server A computer dedicated to responding to requests (from the browser client) for web pages

15-63 Bandwidth

• Data rate measured in bits (not bytes) per seconds • Kbps (Kilobits per seconds) – 125 chars/sec • Mbps (Megabits per seconds) – 1,250 chars/sec • Gbps (Gigabits per seconds) – 12,500 chars/sec Types of Networks

• Local-area network (LAN) A network that connects a relatively small number of machines in a relatively close geographical area

15-65 Types of Networks

• Various configurations, called topologies, have been used to administer LANs – Ring topology A configuration that connects all nodes in a closed loop on which messages travel in one direction – Star topology A configuration that centers around one node to which all others are connected and through which all messages are sent – Bus topology All nodes are connected to a single communication line that carries messages in both directions

15-66 Types of Networks

Figure 15.2 Various network topologies • A bus technology called Ethernet has become the industry standard for local-area networks 15-10 Types of Networks

• Wide-area network (WAN) A network that connects two or more local-area networks over a potentially large geographic distance Often one particular node on a LAN is set up to serve as a gateway to handle all communication going between that LAN and other networks Communication between networks is called The , as we know it today, is essentially the ultimate wide-area network, spanning the entire globe

15-68 Types of Networks

• Metropolitan-area network (MAN) The communication infrastructures that have been developed in and around large cities

15-69 Network Hardware

• Hub OSI Model Layers – An unintelligent network device that sends one signal to all of the stations 7 Application connected to it. 6 Presentation – All computers/devices are competing 5 Session for attention because it takes the data 4 Transport that comes into a port and sends it out 3 Network all the other ports in the hub. 2 Data Link – Traditionally, hubs are used for star 1 Physical topology networks, but they are often used with other configurations to make it easy to add and remove computers without bringing down the network. – Resides on Layer 1 of the OSI model Network Hardware

• Switch OSI Model Layers – Split large networks into small segments, decreasing the number of 7 Application users sharing the same network 6 Presentation resources and bandwidth. 5 Session – Understands when two devices want 4 Transport to talk to each other, and gives them a 3 Network switched connection 2 Data Link – Helps prevent data collisions and 1 Physical reduces network congestion, increasing network performance. – Most home users get very little, if any, advantage from switches, even when sharing a broadband connection. – Resides on Layer 2 of the OSI model. Network Hardware

• Bridge OSI Model Layers – Connects two LANs and forwards or 7 Application filters data packets between them. 6 Presentation – Creates an extended network in which 5 Session any two workstations on the linked 4 Transport LANs can share data. 3 Network – Transparent to protocols and to higher 2 Data Link level devices like routers. 1 Physical – Forward data depending on the Hardware (MAC) address, not the Network address (IP). – Resides on Layer 2 of the OSI model. Network Hardware

OSI Model Layers – Used to boost the signal between two 7 Application cable segments or wireless access 6 Presentation 5 Session points. 4 Transport – Can not connect different network 3 . 2 Data Link 1 Physical – Does not simply amplify the signal, it regenerates the packets and retimes them. – Resides on Layer 1 of the OSI model. Network Hardware

• Router OSI Model Layers – A device that connects any number of LANs. 7 Application – Uses standardized protocols to move packets 6 Presentation efficiently to their destination. 5 Session – More sophisticated than bridges, connecting 4 Transport networks of different types (for example, star 3 Network and ) 2 Data Link – Forwards data depending on the Network 1 Physical address (IP), not the Hardware (MAC) address. – Routers are the only one of these four devices that will allow you to share a single IP address among multiple network clients. – Resides on Layer 3 of the OSI model. Network Hardware

• Additional Network Hardware Devices – Network Interface Cards (NICs) • Puts the data into packets and transmits packet onto the network. • May be wired or wireless. – Gateway • Connects networks with different protocols like TCP/IP network and IPX/SPX networks. • Routers and Gateways often refer to the same device. – • Isolates internal network computers from the internet. • The user first access the proxy server and the proxy server accesses the internet and retrieves the requested web page or document. The user then gets a copy of that page from the proxy server.

Source: http://www.camas.wednet.edu/chs/tech/computer_tech/info/routers_hubs_bridges.htm Computer Software

• Computer hardware is useless without software. • Software is the set of instructions and associated data that direct the computer to do a task. • Software can be divided into two categories: • system software and application software. • System software helps the computer to carry out its basic operating tasks. • Application software helps the user carry out a variety of tasks. The major types of software

System Software

Application software Operating Systems System software Schedules computer events Allocates computer Hardware resources Monitor events

Language translators Interpreters Users Compilers

Application Software Utility programs Programming languages Routine operations (e.g. sort, Assembly language list, print) FORTRAN, BASIC, PL/1 Manage data (e.g. create files, PASCAL, C merge files “4th generation “ languages Software Categories

Chapter 3: Computer Software 78 System Software

• Manages the fundamental operations of the computer, such as - loading programs and data into memory, executing programs, saving data to disks, displaying information on the monitor, and transmitting data through a port to a peripheral device. • System software: operating systems, utilities, device drivers.

Operating System • Collection of computer programs that control the interaction of the user and the computer hardware. • Responsible for directing all computer operations and managing all computer resources. • Controls basic input and output, allocates system resources, manages storage space, maintains security, and detects equipment failure. • A part of the operating system code is stored in a ROM and the rest of it resides on a disk. • Loading the operating system into memory is called booting the computer. Application Software

• Productivity software can be defined as any type of application software that has the potential to help people do their work more efficiently • Groupware is designed to help several people collaborate on a single project using local networks or Internet connections

Chapter 3: Computer Software 82 Utility Software

• Utility software (a type of system software) is designed to help you monitor and configure settings for your computer system equipment, the operating system, or application software • A desktop widget is a specialized utility program that appears on a computer’s screen-based desktop

Chapter 3: Computer Software 83 Device Drivers

• A device driver is software that helps a peripheral device establish communication with a computer • Windows Device Manager

Chapter 3: Computer Software 84