COMPUTER PROGRAMMING LECTURE NOTES

3y ago
16 Views
2 Downloads
1.71 MB
171 Pages
Last View : 26d ago
Last Download : 3m ago
Upload by : Adele Mcdaniel
Transcription

COMPUTER PROGRAMMINGLECTURE NOTESYear:2016 - 2017Subject Code:ACS001Regulations:R16Class:I B.TechBranch:CSE/ ECE/ IT/ EEETeam of Instructors:Dr. K Srinivasa Reddy, Professor, CSE,Dr. G Ramu, Professor, CSE,Ms. B Padmaja, Associate Professor, CSE,Ms. P. Ila Chandana Kumari, Associate Professor, IT,Ms. K. Laxmi Narayanamma, Associate Professor, IT,Ms. B Rekha, Assistant Professor, ITPrepared By:Ms. P. Ila Chandana Kumari, Associate Professor, ITINSTITUTE OF AERONAUTICAL ENGINEERING(Autonomous)Dundigal, Hyderabad - 500 0431

UNIT-IINTRODUCTION TO COMPUTERSCOMPUTER SYSTEMS―A Computer is an electronic device that stores, manipulates and retrieves the data.‖We can also refer computer computes the information supplied to it and generates data.A System is a group of several objects with a process. For Example: Educational Systeminvolves teacher, students (objects). Teacher teaches subject to students i.e., teaching (process).Similarly a computer system can have objects and process.The following are the objects of computer Systema) User ( A person who uses the computer)b) Hardwarec) SoftwareHardware:Hardware of a computer system can be referred as anything which we can touch andfeel. Example : Keyboard and Mouse.The hardware of a computer system can be classified asInput Devices(I/P)Processing Devices (CPU)Output Devices(O/P)KEYBOARDINPUTALU, CU,MUCPUMONITOROUTPUTALU: It performs the Arithmetic and Logical Operations such as ,-,*,/(Arithmetic Operators)&&, ( Logical Operators)CU: Every Operation such as storing , computing and retrieving the data should be governed bythe control unit.2

MU: The Memory unit is used for storing the data.The Memory unit is classified into two types.They are1) Primary Memory2) Secondary MemoryPrimary memory: The following are the types of memoruies which are treated as primaryROM: It represents Read Only Memory that stores data and instructions even when the computeris turned off. The Contents in the ROM can‘t be modified once if they are written . It is used tostore the BIOS information.RAM: It represents Random Access Memory that stores data and instructions when the computeris turned on. The contents in the RAM can be modified any no. of times by instructions. It isused to store the programs under execution.Cache memory: It is used to store the data and instructions referred by processor.Secondary Memory: The following are the different kinds of memoriesMagnetic Storage: The Magnetic Storage devices store information that can be read, erased andrewritten a number of times.Example: Floppy Disks, Hard Disks, Magnetic TapesOptical Storage: The optical storage devices that use laser beams to read and write stored data.Example:CD(Compact Disk),DVD(Digital Versatile Disk)COMPUTER SOFTWARESoftware of a computer system can be referred as anything which we can feel and see.Example: Windows, iconsComputer software is divided in to two broad categories: system software and applicationsoftware .System software manages the computer resources .It provides the interface between thehardware and the users. Application software, on the other hand is directly responsible forhelping users solve their problems.System SoftwareSystem software consists of programs that manage the hardware resources of a computer andperform required information processing tasks. These programs are divided into three classes:the operating system, system support, and system development.3

The operating system provides services such as a user interface, file and database access, andinterfaces to communication systems such as Internet protocols. The primary purpose of thissoftware is to keep the system operating in an efficient manner while allowing the users access tothe system.System support software provides system utilities and other operating services. Examples ofsystem utilities are sort programs and disk format programs. Operating services consists ofprograms that provide performance statistics for the operational staff and security monitors toprotect the system and data.The last system software category, system development software, includes the languagetranslators that convert programs into machine language for execution ,debugging tools to ensurethat the programs are error free and computer –assisted software engineering(CASE) systems.Application softwareApplication software is broken in to two classes: general-purpose software and application –specific software. General purpose software is purchased from a software developer and can beused for more than one application. Examples of general purpose software include wordprocessors, database management systems ,and computer aided design systems. They are labeledgeneral purpose because they can solve a variety of user computing problems.Application –specific software can be used only for its intended purpose.A general ledger system used by accountants and a material requirements planning system usedby a manufacturing organization are examples of application-specific software. They can be usedonly for the task for which they were designed they cannot be used for other generalized tasks.The relationship between system and application software is shown below. In this figure, eachcircle represents an interface point .The inner core is hard ware. The user is represented by theout layer. To work with the system, the typical user uses some form of application software. Theapplication software in turn interacts with the operating system, which is a part of the systemsoftware layer. The system software provides the direct interaction with the hard ware. Theopening at the bottom of the figure is the path followed by the user who interacts directly withthe operating system when necessary.4

COMPUTING ENVIRONMENTSThe word ‗compute‘ is used to refer to the process of converting information to data. Theadvent of several new kinds of computers created a need to have different computingenvironments.The following are the different kinds of computing environments available1. Personal Computing Environment2. Time Sharing Environment3. Client/Server Environment4. Distributed Computing EnvironmentPersonal Computing EnvironmentIn 1971, Marcian E. Hoff, working for INTEL combined the basic elements of the centralprocessing unit into the microprocessor. If we are using a personal computer then all thecomputer hardware components are tied together. This kind of computing is used to satisfy theneeds of a single user, who uses the computer for the personal tasks.Ex: Personal ComputerTime-Sharing EnvironmentThe concept of time sharing computing is to share the processing of the computer basingon the criteria time. In this environment all the computing must be done by the central computer.5

The complete processing is done by the central computer.The computer which ask forprocessing are only dumb terminals.Client/Server EnvironmentA Client/Server Computing involves the processing between two machines. A clientMachine is the one which requests processing. Server Machine is the one which offers theprocessing.Hence the client is Capable enough to do processing. A portion of processing isdone by client and the core(important) processing is done by Server.Distributed ComputingA distributed computing environment provides a seamless integration of computingfunctions between different servers and clients. A client not just a requestor for processing theinformation from the server. The client also has the capability to process information. All themachines Clients/Servers share the processing task.6

Example: Ebay on InternetCOMPUTER LANGUAGESTo write a program (tells what to do) for a computer, we must use a computer language.Over the years computer languages have evolved from machine languages to natural languages.The following is the summary of computer languages1940‘s--Machine Languages1950‘s--Symbolic Languages1960‘s--High Level LanguagesMachine LanguageIn the earliest days of computers, the only programming languages available weremachine languages. Each computer has its own machine language which is made of streams of0‘s and 1‘s. The instructions in machine language must be in streams of 0‘s and 1‘s. This is alsoreferred as binary digits. These are so named as the machine can directly understood theprogramsAdvantages:1) High speed execution2) The computer can understood instructions immediately3) No translation is needed.Disadvantages:1) Machine dependent2) Programming is very difficult3) Difficult to understand4) Difficult to write bug free programs5) Difficult to isolate an error7

Example Additon of two numbers 2 00103 0011------------------5 ---0101---------------Symbolic Languages (or) Assembly LanguageIn the early 1950‘s Admiral Grace Hopper, a mathematician and naval officer, developedthe concept of a special computer program that would convert programs into machine language.These early programming languages simply mirrored the machine languages using symbols ormnemonics to represent the various language instructions. These languages were known assymbolic languages. Because a computer does not understand symbolic language it must betranslated into the machine language.A special program called an Assembler translatessymbolic code into the machine language. Hence they are called as Assembly language.Advantages:1) Easy to understand and use2) Easy to modify and isolate error3) High efficiency4) More control on hardwareDisadvantages:1) Machine Dependent Language2) Requires translator3) Difficult to learn and write programs4) Slow development time5) Less efficientExample:2PUSH 2,A3PUSH 3,B ADD A,B5PRINT C8

High-Level LanguagesThe symbolic languages greatly improved programming efficiency they stillrequired programmers to concentrate on the hardware that they were using working withsymbolic languages was also very tedious because each machine instruction had to beindividually coded. The desire to improve programmer efficiency and to change the focus fromthe computer to the problems being solved led to the development of high-level languages.High-level languages are portable to many different computer allowing the programmerto concentrate on the application problem at hand rather than the intricacies of the computer.CA systems implementation LanguageC C with object oriented enhancementsJAVAObject oriented language for internet and general applications using basic C syntaxAdvantages:1) Easy to write and understand2) Easy to isolate an error3) Machine independent language4) Easy to maintain5) Better readability6) Low Development cost7) Easier to document8) PortableDisadvantages:1) Needs translator2) Requires high execution time3) Poor control on hardware4) Less efficientExample:C language#include stdio.h void main(){int a,b,c;scanf("%d%d%",&a,&b);9

c a b;printf("%d",c);}Difference between Machine, Assembly, High Level LanguagesFeatureMachineAssemblyHigh LevelForm0‘s and 1‘sMnemonic codesNormal EnglishMachine t NeededNeeded(Assembler)Needed(Compiler)Execution TimeLessLessHighLanguagesOnly oneDifferent ManufactgurersDifferent LanguagesNatureDifficultDifficultEasyMemory SpaceLessLessMoreLanguage TranslatorsThese are the programs which are used for converting the programs in one language intomachine language instructions, so that they can be excuted by the computer.1)Compiler:It is a program which is used to convert the high level languageprograms into machine language2)Assembler:It is a program which is used to convert the assembly levellanguage programs into machine language3)Interpreter: It is a program, it takes one statement of a high level languageprogram, translates it into machine language instruction and then immediatelyexecutes the resulting machine language instruction and so on.Comparison between a Compiler and InterpreterCOMPILERINTERPRETERA Compiler is used to compile an entireAn interpreter is used to translate each line ofprogram and an executable program isthe program code immediately as it is enteredgenerated through the object program10

The executable program is stored in a disk forThe executable program is generated in RAMfuture use or to run it in another computerand the interpreter is required for each run ofthe programThe compiled programs run fasterThe Interpreted programs run slowerMost of the Languages use compilerA very few languages use interpreters.CREATING AND RUNNING PROGRAMSThe procedure for turning a program written in C into machine Language. The process ispresented in a straightforward, linear fashion but you shuld recognize that these steps arerepeated many times during development to correct errors and make improvements to the code.The following are the four steps in this process1)Writing and Editing the program2)Compiling the program3)Linking the program with the required modules4)Executing the program11

TEXT EDITORCOMPILERLINKERLibraryRUNNEROUTPUTSl. No.PhaseName of CodeToolsFile Extension1TextEditorSource CodeC Compilers.CEdit,Notepad Etc.,2CompilerObject CodeC Compiler.OBJ3LinkerExecutableC Compiler.EXEC Compiler.EXECode4RunnerExecutableCodeWriting and Editing ProgramsThe software used to write programs is known as a text editor. A text editor helpsus enter, change and store character data. Once we write the program in the text editor we save itusing a filename stored with an extension of .C. This file is referred as source code file.12

Compiling ProgramsThe code in a source file stored on the disk must be translated into machine language.This is the job of the compiler. The Compiler is a computer program that translates the sourcecode written in a high-level language into the corresponding object code of the low-levellanguage. This translation process is called compilation. The entire high level program isconverted into the executable machine code file. The Compiler which executes C programs iscalled as C Compiler. Example Turbo C, Borland C, GC etc.,The C Compiler is actually two separate programs:The PreprocessorThe TranslatorThe Preprocessor reads the source code and prepares it for the translator. While preparing thecode, it scans for special instructions known as preprocessor commands. These commands tellthe preprocessor to look for special code libraries. The result of preprocessing is called thetranslation unit.After the preprocessor has prepared the code for compilation, the translator does theactual work of converting the program into machine language.The translator reads thetranslation unit and writes the resulting object module to a file that can then be combined withother precompiled units to form the final program. An object module is the code in the machinelanguage.Linking ProgramsThe Linker assembles all functions, the program‘s functions and system‘s functions intoone executable program.Executing ProgramsTo execute a program we use an operating system command, such as run, to load theprogram into primary memory and execute it. Getting the program into memory is the functionof an operating system program known as the loader. It locates the executable program and13

reads it into memory.When everything is loaded the program takes control and it beginexecution.ALGORITHMAlgorithm is a finite sequence of instructions, each of which has a clear meaning and can beperformed with a finite amount of effort in a finite length of time. No matter what the inputvalues may be, an algorithm terminates after executing a finite number of instructions.We represent an algorithm using a pseudo language that is a combination of the constructs of aprogramming language together with informal English statements.The ordered set of instructions required to solve a problem is known as an algorithm.The characteristics of a good algorithm are: Precision– the steps are precisely stated (defined). Uniqueness– results of each step are uniquely defined and only depend on the inputand the result of the preceding steps. Finiteness Input– the algorithm stops after a finite number of instructions are executed.– the algorithm receives input. Output– the algorithm produces output. Generality –the algorithm applies to a set of inputs.ExampleQ. Write a algorithem to find out number is odd or even?Ans.step 1 : startstep 2 : input numberstep 3 : rem number mod 2step 4 : if rem 0 thenprint "number even"elseprint "number odd"endifstep 5 : stopFLOWCHARTFlowchart is a diagrammatic representation of an algorithm. Flowchart is very helpful in writingprogram and explaining program to others.14

Symbols Used In FlowchartDifferent symbols are used for different states in flowchart, For example: Input/Output anddecision making has different symbols. The table below describes all the symbols that are used inmaking flowchartSymbolPurposeFlow lineDescriptionUsed to indicate the flow of logic by connectingsymbols.Terminal(Stop/Start)Used to represent start and end of flowchart.Input/OutputUsed for input and output operation.ProcessingDesicionUsed for airthmetic operations and datamanipulations.Used to represent the operation in which there aretwo alternatives, true and false.On-page ConnectorUsed to join different flowlineOff-page ConnectorUsed to connect flowchart portion on different page.PredefinedUsed to represent a group of statements performingProcess/Functionone processing task.Examples of flowcharts in programmingDraw a flowchart to add two numbers entered by user.15

Draw flowchart to find the largest among three different numbers entered by user.INTRODUCTION TO C LANGUAGEC is a general-purpose high level language that was originally developed by Dennis Ritchie forthe Unix operating system. It was first implemented on the Digital Eqquipment CorporationPDP-11 computer in 1972.16

The Unix operating system and virtually all Unix applications are written in the C language. Chas now become a widely used professional language for various reasons. Easy to learn Structured language It produces efficient programs. It can handle low-level activities. It can be compiled on a variety of computers.Facts about C C was invented to write an operating system called UNIX. C is a successor of B language which was introduced around 1970 The language was formalized in 1988 by the American National Standard Institue(ANSI). By 1973 UNIX OS almost totally written in C. Today C is the most widely used System Programming Language. Most of the state of the art software have been implemented using CWhy to use C?C was initially used for system development work, in particular the programs that make-up theoperating system. C was adoped as a system development language because it produces code thatruns nearly as fast as code written in assembly language. Some examples of the use of C mightbe: Operating Systems Language Compilers Assemblers Text Editors Print Spoolers Network Drivers Modern Programs Data Bases Language Interpreters UtilitiesC Program File17

All the C programs are writen into text files with extension ".c" for example hello.c. You can use"vi" editor to write your C program into a file.HISTORY TO C LANGUAGEC is a general-purpose language which has been closely associated with the UNIX operatingsystem for which it was developed - since the system and most of the programs that run it arewritten in C.Many of the important ideas of C stem from the language BCPL, developed by Martin Richards.The influence of BCPL on C proceeded indirectly through the language B, which was written byKen Thompson in 1970 at Bell Labs, for the first UNIX system on a DEC PDP7. BCPL and B are "type less" languages whereas C provides a variety of data types.In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the publication of The C ProgrammingLanguage by Kernighan & Ritchie caused a revolution in the computing world.In 1983, the American National Standards Institute (ANSI) established a committee to provide amodern, comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSIC", was compl

language programs into machine language 3) Interpreter: It is a program, it takes one statement of a high level language program, translates it into machine language instruction and then immediately executes the resulting machine language instruction and so on. Comparison between a Compiler and Interpreter COMPILER INTERPRETER

Related Documents:

Introduction of Chemical Reaction Engineering Introduction about Chemical Engineering 0:31:15 0:31:09. Lecture 14 Lecture 15 Lecture 16 Lecture 17 Lecture 18 Lecture 19 Lecture 20 Lecture 21 Lecture 22 Lecture 23 Lecture 24 Lecture 25 Lecture 26 Lecture 27 Lecture 28 Lecture

Lecture 1: A Beginner's Guide Lecture 2: Introduction to Programming Lecture 3: Introduction to C, structure of C programming Lecture 4: Elements of C Lecture 5: Variables, Statements, Expressions Lecture 6: Input-Output in C Lecture 7: Formatted Input-Output Lecture 8: Operators Lecture 9: Operators continued

GEOMETRY NOTES Lecture 1 Notes GEO001-01 GEO001-02 . 2 Lecture 2 Notes GEO002-01 GEO002-02 GEO002-03 GEO002-04 . 3 Lecture 3 Notes GEO003-01 GEO003-02 GEO003-03 GEO003-04 . 4 Lecture 4 Notes GEO004-01 GEO004-02 GEO004-03 GEO004-04 . 5 Lecture 4 Notes, Continued GEO004-05 . 6

2 Lecture 1 Notes, Continued ALG2001-05 ALG2001-06 ALG2001-07 ALG2001-08 . 3 Lecture 1 Notes, Continued ALG2001-09 . 4 Lecture 2 Notes ALG2002-01 ALG2002-02 ALG2002-03 . 5 Lecture 3 Notes ALG2003-01 ALG2003-02 ALG

Artificial Intelligence COMP-424 Lecture notes by Alexandre Tomberg Prof. Joelle Pineau McGill University Winter 2009 Lecture notes Page 1 . I. History of AI 1. Uninformed Search Methods . Lecture notes Page 58 . Lecture notes Page 59 . Soft EM for a general Bayes net: Lecture notes Page 60 . Machine Learning: Clustering March-19-09

Lecture 1: Introduction and Orientation. Lecture 2: Overview of Electronic Materials . Lecture 3: Free electron Fermi gas . Lecture 4: Energy bands . Lecture 5: Carrier Concentration in Semiconductors . Lecture 6: Shallow dopants and Deep -level traps . Lecture 7: Silicon Materials . Lecture 8: Oxidation. Lecture

TOEFL Listening Lecture 35 184 TOEFL Listening Lecture 36 189 TOEFL Listening Lecture 37 194 TOEFL Listening Lecture 38 199 TOEFL Listening Lecture 39 204 TOEFL Listening Lecture 40 209 TOEFL Listening Lecture 41 214 TOEFL Listening Lecture 42 219 TOEFL Listening Lecture 43 225 COPYRIGHT 2016

Partial Di erential Equations MSO-203-B T. Muthukumar tmk@iitk.ac.in November 14, 2019 T. Muthukumar tmk@iitk.ac.in Partial Di erential EquationsMSO-203-B November 14, 2019 1/193 1 First Week Lecture One Lecture Two Lecture Three Lecture Four 2 Second Week Lecture Five Lecture Six 3 Third Week Lecture Seven Lecture Eight 4 Fourth Week Lecture .