O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

01 Programming for Problem Solving.pdf

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Carregando em…3
×

Confira estes a seguir

1 de 48 Anúncio

Mais Conteúdo rRelacionado

Semelhante a 01 Programming for Problem Solving.pdf (20)

Mais recentes (20)

Anúncio

01 Programming for Problem Solving.pdf

  1. 1. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year PROGRAMMING FOR PROBLEM SOLVING 1FY3- 06 Fundamentals of Computer By SANTOSH KUMAR ASST. PROF CSE/IT, GIT Jaipur Contents Syllabus Marks distribution Objective of course Book
  2. 2. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Computer Data Processing
  3. 3. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year
  4. 4. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Objective of the Course: The course is designed to understand the concept of programming language, to know about memory unit and understanding various binary codes and to enhance the programming skills of the students by giving practical assignments to be done in labs. Books Recommended for Reading and Reference: 1. Ritchie & Kernighan, The C Programming language, 2nd Ed., PHI. 2. Yashwant Kanetkar, Let us C, 7edition. BPB Publication, 2009. 3. Dey & Ghosh, Computer Fundamentals and programming in C, Oxford. 4. Balaguruswamy, Programming in ANSI C, 5th Ed., TMH. 5. Rajaraman, Fundamentals of Computers, 5th Ed. PHI, 2011. 6. P. K. Sinha & P. Sinha, Computer fundamentals Learning Outcomes: After the completion of the course, the students will •To bridge the gap between the knowhow of Fundamental of Computer Programming and its actual application and implementation in the field of computer science & engineering.
  5. 5. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •To make students able to understand the concepts of Programming and its mechanism so that he/she is able to define the solution of different problems via algorithms Computer •The word computer comes from the word “compute” , which means, “to calculate” •Thereby, a computer is an electronic device that can perform arithmetic operations at high speed •A computer is also called a data processor because it can store, process, and retrieve data whenever desired Data Processing •The activity of processing data using a computer is called data processing
  6. 6. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Data is raw material used as input and information is processed data obtained as output of data processing. The Five Basic Operations of a Computer System •Inputting. The process of entering data and instructions into the computer system
  7. 7. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Storing. Saving data and instructions to make them readily available for initial or additional processing whenever required •Processing. Performing arithmetic operations (add, subtract, multiply, divide, etc.) or logical operations (comparisons like equal to, less than, greater than, etc.) on data to convert them into useful information •Outputting. The process of producing useful information or results for the user such as a printed report or visual display •Controlling. Directing the manner and sequence in which all of the above operations are performed The Five Basic Operations of a Computer System •Inputting. The process of entering data and instructions into the computer system
  8. 8. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Storing. Saving data and instructions to make them readily available for initial or additional processing whenever required •Processing. Performing arithmetic operations (add, subtract, multiply, divide, etc.) or logical operations (comparisons like equal to, less than, greater than, etc.) on data to convert them into useful information •Outputting. The process of producing useful information or results for the user such as a printed report or visual display •Controlling. Directing the manner and sequence in which all of the above operations are performed
  9. 9. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Basic Organization of a Computer System
  10. 10. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Input Unit An input unit of a computer system performs the following functions: 1. It accepts (or reads) instructions and data from outside world 2. It converts these instructions and data in computer acceptable form 3. It supplies the converted instructions and data to the computer system for further processing
  11. 11. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Output Unit An output unit of a computer system performs the following functions: 1. It accepts the results produced by the computer, which are in coded form and hence, cannot be easily understood by us 2. It converts these coded results to human acceptable (readable) form 3. It supplies the converted results to outside world
  12. 12. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Storage Unit The storage unit of a computer system holds (or stores) the following : 1. Data and instructions required for processing (received from input devices) 2. Intermediate results of processing 3. Final results of processing, before they are released to an output device Two Types of Storage Primary storage •Used to hold running program instructions •Used to hold data, intermediate results, and results of ongoing processing of job(s) •Fast in operation •Small Capacity
  13. 13. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Expensive •Volatile (looses data on power dissipation) Two Types of Storage Secondary storage •Used to hold stored program instructions •Used to hold data and information of stored jobs •Slower than primary storage •Large Capacity •Lot cheaper that primary storage •Retains data even without power Arithmetic Logic Unit (ALU) Arithmetic Logic Unit of a computer system is the place where the actual executions of instructions takes place during processing operation
  14. 14. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Control Unit (CU) Control Unit of a computer system manages and coordinates the operations of all other components of the computer system Central Processing Unit (CPU) •It is the brain of a computer system •It is responsible for controlling the operations of all other units of a computer system
  15. 15. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year A computer is a system as it comprises of integrated components (input unit, output unit, storage unit, and CPU) that work together to perform the steps called for in the executing program Main Memory •Every computer has a temporary storage built into the computer hardware •It stores instructions and data of a program mainly when the program is being executed by the CPU. •This temporary storage is known as main memory, primary storage, or simply memory. •Physically, it consists of some chips either on the motherboard or on a small circuit board attached to the motherboard of a computer.
  16. 16. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •It has random access property. •It is volatile. Random Access Memory (RAM) •Primary storage of a computer is often referred to as RAM because of its random access capability •RAM chips are volatile memory •A computer’s motherboard is designed in a manner that the memory capacity can be enhanced by adding more memory chips
  17. 17. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •The additional RAM chips, which plug into special sockets on the motherboard, are known as single-in-line memory modules (SIMMs) Read Only Memory (ROM) •ROM a non-volatile memory chip •Data stored in a ROM can only be read and used – they cannot be changed •ROMs are mainly used to store programs and data, which do not change and are frequently used. For example, system boot program
  18. 18. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Types of ROMs Type Usage Manufacturer-programmed ROM Data is burnt by the manufacturer of the electronic equipment in which it is used. User-programmed ROM or Programmable ROM (PROM) The user can load and store “read-only” programs and data in it Erasable PROM (EPROM) The user can erase information stored in it and the chip can be reprogrammed to store new information Ultra Violet EPROM (UVEPROM) A type of EPROM chip in which the stored information is erased by exposing the chip for some time to ultra-violet light
  19. 19. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Electrically EPROM (EEPROM) or Flash memory A type of EPROM chip in which the stored information is erased by using high voltage electric pulses Cache Memory •It is commonly used for minimizing the memory processor speed mismatch. •It is an extremely fast, small memory between CPU and main memory whose access time is closer to the processing speed of the CPU. •It is used to temporarily store very active data and instructions during processing.
  20. 20. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Cache is pronounced as “cash” Limitations of Primary Storage •Limited capacity because the cost per bit of storage is high •Volatile - data stored in it is lost when the electric power is turned off or interrupted
  21. 21. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Secondary Storage •Used in a computer system to overcome the limitations of primary storage •Has virtually unlimited capacity because the cost per bit of storage is very low •Has an operating speed far slower than that of the primary storage •Used to store large volumes of data on a permanent basis •Also known as auxiliary memory
  22. 22. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Classification of Commonly Used Secondary Storage Devices
  23. 23. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year
  24. 24. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Floppy Disk • The most common secondary storage device • 3.5” disk – 1.44MB
  25. 25. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Hard Disk Drive or Hard Disk • Made of rigid materials unlike floppy disks • Holds a greater amount of data
  26. 26. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Optical Discs • A standard part of modern desktop machines, especially used for multimedia purposes and preferred in loading applications.
  27. 27. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year
  28. 28. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Kinds • Blue Ray Disk – 40G • Digital Versatile Disk – DVD-R – write once, 3.95G – DVD RW – rewritable, 3G – Single Layer and Double Layer • Compact Disk – CD-R – write once, 650MB – CD-RW – rewritable, 700MB Optical Drives
  29. 29. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year • CD-ROM read CDs • CD-Writer read/write CDs • DVD-Combo read/write CDs, read DVD • DVD Writer read/write CDs read/write DVDs Other Secondary Storage • Solid-State Storage
  30. 30. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year – No moving parts – Flash memory cards – USB flash drives
  31. 31. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Storage Evaluation Criteria Property Desirable Primary storage Secondary storage Storage capacity Large storage capacity Small Large Access Time Fast access time Fast Slow Cost per bit of storage Lower cost per bit High Low Volatility Non-volatile Volatile Non-volatile
  32. 32. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Access Random access Random access Pseudorandom access or sequential access ACCESSMETHODS •When we design a file, the important issue is how we will retrieve information (a specific record) from the file. •Sometimes we need to process records one after another, whereas sometimes we need to access a specific record quickly without retrieving the preceding records.
  33. 33. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •The access method determines how records can be retrieved: sequentially, randomly and direct. ACCESSMETHODS Sequential access If we need to access a file sequentially—that is, one record after another, from beginning to end —we use a sequential file structure. Random access If we need to access a specific record without having to retrieve all records before it, we use a file structure that allows random access. Direct access direct access is the ability to obtain data from a storage device by going directly to where it is
  34. 34. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year physically located on the device rather than by having to sequentially look for the data at one physical location after another. COMPUTER LANGUAGES •To communicate with the computers, we need some languages. These are computer languages. •There are mainly three different languages with the help of which we can develop computer programs. •And they are – 1. Machine Level language
  35. 35. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year 2. Assembly Level Language and 3. High Level Language Machine Level Language •Computer can understand only the language of Digital Electronics. Digital Electronics deals with presence and absence of voltages. Within the computer there are two logics can play their role. •These logics are – 1. Positive Logic – Here presence of voltage will be denoted by 1 and absence of voltage will be denoted by 0
  36. 36. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year 2. Negative Logic – Here presence of voltage will be denoted by 0 and absence of voltage will be denoted by 1 Assembly Level Language •After machine level language, the next level of development in the evolution of computer languages was the Assembly Language. •Machine level language uses only the binary language. But on the other hand, assembly language uses mnemonics or symbolic instructions in place of a sequence of 0s and 1s. •Example : - we can consider that, to add register A and B in a particular computer, assembly language uses the mnemonic ‘ADD B’ in place of 10001111. In assembly language, we use symbolic names to denote addresses and data.
  37. 37. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Thus writing a program in assembly language has advantages over writing the same in a machine language. High Level Language •High level language is the next development in the evolution of computer languages. •Examples of some high-level languages are given below – •C/C++ •JAVA •Pascal (named after the French scientist Blaise Pascal) •High-level languages are like English-like language, with less words also known as keywords and fewer ambiguities.
  38. 38. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year •Each high level language will have its own syntax and keywords. The meaning of the word syntax is grammar.
  39. 39. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart ALGORITHM: •An algorithm is a sequence of steps to solve a particular problem or algorithm is an ordered set of unambiguous steps that produces a result and terminates in a finite time •Algorithm has the following characteristics 1. Input: An algorithm may or may not require input 2. Output: Each algorithm is expected to produce at least one result 3. Definiteness: Each instruction must be clear and unambiguous.
  40. 40. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart 4. Finiteness: If the instructions of an algorithm are executed, the algorithm should terminate after finite number of steps Advantages of algorithm: •It is a step-wise representation of a solution to a given problem, which makes it easy to understand. • An algorithm uses a definite procedure. • It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge. •Every step in an algorithm has its own logical sequence so it is easy to debug.
  41. 41. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart Flowchart: •Flowchart is diagrammatic /Graphical representation of sequence of steps to solve a problem. •Flowchart uses different symbols to design a solution to a problem. It is another commonly used programming tool. •By looking at a Flowchart one can understand the operations and sequence of operations performed in a system. •Flowchart is often considered as a blueprint of a design used for solving a specific problem.
  42. 42. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart Advantages of Flowchart : •Flowchart is an excellent way of communicating the logic of a program. •Easy and efficient to analyze problem using flowchart. • During program development cycle, the flowchart plays the role of a blueprint, which makes program development process easier. • After successful development of a program, it needs continuous timely maintenance during the course of its operation. The flowchart makes program or system maintenance easier. • It is easy to convert the flowchart into any programming language code.
  43. 43. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart To draw a flowchart following standard symbols are use
  44. 44. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart
  45. 45. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart
  46. 46. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart
  47. 47. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart
  48. 48. GLOBAL INSTITUTE OF TECHNOLGY JAIPUR PROGRAMMING FOR PROBLEM SOLVING Ist Year Algorithm & Flowchart

×