×
WORK HARD UNTIL LAMP LIGHT OF STUDY TABLE BECOMES SPOT LIGHT OF STAGE.
--Your friends at LectureNotes
Close

Programming in C

by Amity KumarAmity Kumar
Type: NoteInstitute: Amity University Specialization: Computer Science EngineeringOffline Downloads: 133Views: 6228Uploaded: 11 months ago

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Amity Kumar
Amity Kumar
Computer Concepts and C Language -Prof. Niranjan N.Chiplunkar What is a Computer? Data is very important for business, science, research etc. As the volume of data is increasing , manual maintenance of this data is really challenging. Moreover, most tasks demand accuracy and the speed in data processing and reporting. Thus a powerful tool to carryout the task of storing, processing and reporting has evolved – which is called a Computer Computer is an electronic device used to store, retrieve and process data. Data is unprocessed facts, figures and statistics. Information is the meaningful output of processed data. To convert raw data into useful information there is a standard process. To carry out this process, a finite and ordered set of instructions are needed. Computers can be classified as digital, analog and hybrid computers based on the technology on which they are built. Analog computers are normally built using Operational Amplifiers. Digital computers are built using digital logic gates . Hybrid computers will have mix of analog and digital components. First generation digital computers were built using vacuum tubes. They were very slow, had very small memory capacity and used to occupy a large space. Second generation computers used transistors. Third generation computers used Integrated circuits(IC). As there was tremendous progress in the IC technology, VLSI (very large Scale Integration Circuits) chips became very common and present day computers are built using VLSI chips. Microprocessors which are the heart of the digital computer are built using VLSI chips. Intel is one of the important manufacturer of the microprocessor chips and Pentium is the family of recent microprocessors which are used as the CPUs of present day computers. Based on the size and capability, digital computers are also classified as Mainframe computers, Mini computers and microcomputers. Super computers are the ones which have tremendous processing power, memory capacity and work very fast. Several microprocessors are interconnected to carry out complex task in less time. PC is the acronym used for Personal Computers. Present day PCs are very powerful and their processors will have several cores of execution units. These are called multi core processor chips. Multi core is the recent technology in processors where more than one core of central processing unit is made available on a single microprocessor chip. The multiple cores execute different portions of the application program simultaneously and thus improving the performance of the system. If there are two cores on a microprocessor chip then it is called dual core processor. Hardware Components of a Digital Computer: Processor, Input/Output devices, and memory are the important components of a digital computer. Processor will have ALU (Arithmetic Logic Unit) and Control 1
Unit(CU) as its components. Memory can be subdivided into primary and secondary memory. Processor is responsible for fetching and executing program instructions. Memory is where data and program are stored. If there is no distinction between data and program memory and if memory is separate from that of CPU then it is called Von Neumann architecture (Harvard architecture is one where there is separate storage for program and data and separate pathways to connect to them). Stored program digital computer is one which stores both program and data in a read-write random access memory. “Von Neumann” and “stored program” are two terminologies which are normally used interchangeably. In the memory, the information is stored in terms of bits or bytes or words. Byte is made of 8 bits and word is a collection of 16, 32 or 64 bits. Memory can be volatile or non volatile. Information present in Volatile memory is lost as soon as the power is turned off. Figure-1 gives the classification of memory devices in a digital computer. Memory Secondary Main Cache RAM ROM Internal Registers External Figure-1: Classification of Memory Secondary memories are non volatile in nature. Examples of secondary memory include Hard disk, Pen drive, DVD-ROM, Recordable DVD,CD-RW, Blue-Ray, Magnetic tapes. Main memory devices are ones in which any memory location can be accessed in any order (not necessarily in a sequential order). RAM (Random Access Memory) and ROM(Read Only Memory) are the two types of main memory devices. RAM is also called Read-Write Memory. It is volatile memory. ROM is non-volatile memory. It is also considered an example of firmware. Cache memory is a memory placed between CPU and main memory. It contains a part of main memory content. Processor when needs some information, first looks in the cache. If not found in cache, the portion of memory containing the needed information is moved to the cache and is also read by the processor. Both internal and external cache 2
memories are volatile in nature. External cache is mounted on the motherboard. Registers are small memory units internally available within the processor. Input devices accept data and control signals from the user. Output devices communicate the processed data to the user. Examples of input devices are keyboard, mouse, pen based systems, data scanners, game controllers, voice recognition systems etc. Examples of output devices are Monitor, Printer, Plotter, sound system etc. Central Processing Unit (CPU) -It is the brain of the computer. It performs the bulk of the data processing operations. The function of the processor is to fetch the instruction from memory, examine (decode) the instruction and execute the instructions. It consists of Control unit, Arithmetic Logic Unit (ALU) and registers. Control unit is responsible for fetching the instructions from memory and interpreting them. ALU performs arithmetic and logical operations. Registers are very high speed memory units for storing very small amount of data. Program counter, Instruction register, Memory address register, memory buffer register and accumulator are some examples of registers. Bus is a collection of wires. They may be unidirectional or bidirectional. Bus is used to connect different parts of a computer. Bus may be serial or parallel. USB is an example of a serial bus. Bus connecting computer and a dot matrix printer is normally a parallel bus. Parallel bus carries several bits at a time. These bits may indicate instruction, data, address or commands. Bus width and Bus speed are the two major components for performance measure of a computer. Software Collection of computer programs, procedures and documentation that perform some tasks on a computer is called software. Software can be categorized as application software and system software. -Application software is developed to solve a specific problem. Examples: Notepad, Wordpad, Microsoft excel, MSAccess etc.. System software provides a convenient environment for program development and execution. Examples: Operating system, assemblers, compilers, interpreters, loaders and linkers etc…. Compiler converts a high level program to a binary level program called object code. Interpreter also does the same thing, but line by line and it also executes the line of code. Operating system is responsible for the management of resources of computer. Examples of Operating system: DOS,Windows, Unix, Linux, Mac, Solaris, AIX etc… DOS (Disk Operating System) is a single user O.S., Unix is a multi user operating system. Windows is multitasking operating system. Linux is a free Unix like operating system. Various versions of Windows operating systems have been released by Microsoft like Windows95, Windows-98,Windows Me, Windows-XP, Windows-Vista, Windows-2003 etc. Unix O.S. was developed by AT&T Bell Labs and comes either as AT&T Unix or BSD Unix. Linux operating system comes in various distributions like Ubuntu, Fedora,redhat etc. Mac O.S. is from Apple company and Solaris is from Sun Microsystems. Networking A computer network, often simply referred to as a network, is a collection of computers and devices connected by communication channels that facilitates communications among users and allows users to share resources with other users. 3
Facilitating Communications, Sharing hardware, sharing files, data and information, sharing software are some of the purposes of Computer network. Computer network can be either Wired and Wireless. Wired networks use twisted pairs, coaxial cable or optical fibre connections. Wireless devices use radio waves or infra red signals for the communication in the free space. A local area network (LAN) is a network that connects computers and devices in a limited geographical area such as home, school, computer laboratory, office building, or closely positioned group of buildings. WAN (Wide Area Network), Campus Network, Enterprise network are other terms used depending on the size of the network. Internet is a Network of Networks at a global level. The Open Systems Interconnection model (OSI model) is a product of the Open Systems Interconnection effort at the International Organization for Standardization. It is a way of sub-dividing a communications system into smaller parts called layers. A layer is a collection of conceptually similar functions that provide services to the layer above it and receives services from the layer below it. Physical, Data link, Network, Transport, Session, Presentation and Application layers are the seven layers (from bottom to top) of OSI reference model Computing Environments There are various computing environments depending on the way in which the computers are used in an application. Personal Computing Environment is a Single user system . In Time Sharing Environment, all computing is done by the central computer. Client Server Environment will have single Server and several clients. Distributed Computing Environment (Eg: e-Bay auction service on the internet) uses several servers and clients. Types of Programming A computer program can be written in either High level programming language or assembly language or machine language. While High level language is comparatively easy to use, Machine language is most difficult. BASIC, FORTRAN, C, Pascal, C++, JAVA, C#, Visual Basic etc. are examples of High level languages. Machine language is made up of 1’s and 0’s. Assembly language is made of mnemonics and has complexity in between the high level and machine level languages. Typical programs are written in sequential manner. This means that, the order of execution of instructions is same as the order in which the instructions are written. Control statements define the flow of program. In the recent multicore processors, to extract the full benefit of the architecture, we need to write multithreaded parallel programs. This can be done using OpenMP pragmas in the C (or FORTRAN) programs. Parallel multithreaded programs also can be written using pthreads and MPI (Message Passing Interface). A program can be designed in a top-down or bottom-up fashion. Procedure oriented languages like Pascal and C help us in writing top-down modular programs. Object oriented languages like C++ and Java are useful in writing bottom-up programs. A Computer Program is a series of steps specified for the solution to a problem, which a computer can understand and execute. A software application is a collection of computer program which address a real life problem for its end users. A software project is an undertaking to create a software application by writing computer programs. 4

Lecture Notes