×
DONT COMPLAIN; JUST WORK HARDER
--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
  • 8959 Views
  • 209 Offline Downloads
  • Uploaded 1 year ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

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

Text from page-6

Chapter 1 Fundamentals and History of C Introduction to C C has emerged as the most widely used programming language for software development. C language supports the powerful low level features like pointer, memory allocation, bit manipulations etc. The features of C language make it possible to se the language for system programming like the development of compiler, interpreter, operating system, system utilities etc. History of C: C language was developed by Dennis Ritchie & Ken Thompson at Bell Laboratories (now part of AT & T) at USA. In 1968, Bell and MIT were doing a joint project on MULTICS (multiplexing information and computing service). Operating system for multi-user-time sharing- system. They are BCPL (Basic combined programming language) developed by Martin Richards at Cambridge University. Around the same time The language called ‘B’ was written by Ken Thompson at Bell Laboratories. Denis Ritchie inherited the features of ‘B’ and BCPL, added some features of his own and developed ‘c’. Computer Definition: A computer is a programmable machine. It allows the user to store all sorts of information and then ‘process’ that information, or data, or carry out actions with the information, such as calculating numbers or organizing words. ADVANTAGES/FEATURES OF C C language has become the language of choice of two decades among system programmers and application programmers. Reason for its popularity can be summarized as follows: 1. Powerful and flexibility: The power and popular UNIX as was written in C. The complier and interpreter for FORTAN, PASCAL, LISP, and BASIC are written in C. 2. Portability: C program written in one system can be run on other system with little modifications. 3. Efficiency: The program written in C language is highly efficient like assembly language in speed and memory management. 4. Programmer oriented: It has the flexible control structure and gives access to hardware and enables to manipulate individual bits of memory. 5. Modularity: 1

Lecture Notes