×
DON'T BE SATISFIED WITH B when you can get A+
--Your friends at LectureNotes
Close

Note for Programming in C - C By Amity Kumar

  • Programming in C - C
  • Note
  • Amity University - AMITY
  • Computer Science Engineering
  • 8 Topics
  • 8902 Views
  • 208 Offline Downloads
  • Uploaded 1 year ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

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

Text from page-3

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

Text from page-4

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

Text from page-5

Software Development Life Cycle (SDLC) The different steps followed in the development of a software project define the software development life cycle. Very popular model is called water fall model, which has steps like requirement gathering, analysis, design, coding , testing , implementation and maintenance. Software engineering (SE) is a profession dedicated to designing, implementing, and modifying software so that it is of higher quality, more affordable, maintainable, and faster to build. As per the software engineering principles, we need to properly design the code before writing it, document the code, use standard coding practices, use proper comments in the code, test the code thoroughly, use version controls and write reusable code . Algorithm, Pseudo Code and Flowchart Algorithm is a finite set of steps to accomplish a task. An algorithm must be finite, definite , effective, with zero or more inputs and with one or more outputs. Pseudo code is English like representation of an algorithm. It is good for a large problem. An algorithm is independent of any language or machine whereas a program is dependent on a language and machine. To fill the gap between the program and the algorithm, we need the pseudo code. Flowchart is a pictorial representation of an algorithm or computation. It is Good for small problems. Flowchart is an organized combination of shapes , lines and text that graphically illustrates a process or structure. Several symbols are used in the flowchart like input box, output box, assignment box, decision box, connection symbol etc. Raptor is a flowchart based programming tool. Raptor stands for “Rapid Algorithmic Prototyping Tool for Ordered Reasoning”. It is a free tool which can be downloaded from the website http://raptor.martincarlisle.com In the software development, errors may creep in at different stages. There could be errors in the algorithm design phase itself. Errors may get detected while compiling the program, which are called syntax errors. The errors which may get detected while executing the program are called run time errors. It is always essential to write error free programs. Reference: Vikas Gupta- Computer Concepts and C Programming, Dreamtech Press 5

Lecture Notes