Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Problem Solving and Programming

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 131 Anuncio

Problem Solving and Programming

Descargar para leer sin conexión

Problem solving skill is the most important skill to be possessed by any student. Most of the time, the emphasis is on learning a programming language rather than on inculcating the problem solving skills. This PPT is designed for use by freshmen students taking their first course in programming. It deals with the techniques needed to practice computational thinking, the art of using computers to solve problems and the ways the computers can be used to solve problems. Problem solving skill is the most important skill to be possessed by any student. Most of the time, the emphasis is on learning a programming language rather than on inculcating the problem solving skills. This course is designed for use by freshmen students taking their first course in programming. It deals with the techniques needed to practice computational thinking, the art of using computers to solve problems and the ways the computers can be used to solve problems. This PPT also focuses on developing programming skills using C language.

Problem solving skill is the most important skill to be possessed by any student. Most of the time, the emphasis is on learning a programming language rather than on inculcating the problem solving skills. This PPT is designed for use by freshmen students taking their first course in programming. It deals with the techniques needed to practice computational thinking, the art of using computers to solve problems and the ways the computers can be used to solve problems. Problem solving skill is the most important skill to be possessed by any student. Most of the time, the emphasis is on learning a programming language rather than on inculcating the problem solving skills. This course is designed for use by freshmen students taking their first course in programming. It deals with the techniques needed to practice computational thinking, the art of using computers to solve problems and the ways the computers can be used to solve problems. This PPT also focuses on developing programming skills using C language.

Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Similares a Problem Solving and Programming (20)

Anuncio

Más de Selvaraj Seerangan (20)

Más reciente (20)

Anuncio

Problem Solving and Programming

  1. 1. 20CST11 – Problem Solving and Programming By Mr.S.Selvaraj Asst. Professor(SRG) / CSE Kongu Engineering College Unit I – Introduction to Computer and Problem Solving
  2. 2. 20CST11 – Problem Solving and Programming 1/7/2021 Introduction to Computers 2 Syllabus
  3. 3. Contents 1. Introduction to Computer 2. Functionalities of Computer 3. Characteristics of Computer 4. Cons of Computers 5. Uses of Computers 6. Types of Computers 7. Generation of Computers 8. Functional Units of Computer 9. Hardware and Software 1/7/2021 3Introduction to Computers
  4. 4. 1. Introduction to Computers • Computers are everywhere: – at workplace – at school – at home • In the workplace, employees use computer to create correspondence such as – e-mail messages, memos, and letters – manage calendars – calculate payroll – track inventory and generate invoices 1/7/2021 4Introduction to Computers
  5. 5. 1. Introduction to Computers • At school, – teachers use computer to assist with classroom instruction. – Students use computers to complete assignments and research. • At home, People also spend hours of leisure time using a computer. – play games – communicate with friend and relatives online and using e-mail – purchase goods online – converse in chat rooms – listen to music or radio broadcasts – watch or create videos and movies – read books and magazines – share stories – research genealogy – retouch photos and plan vacations. 1/7/2021 5Introduction to Computers
  6. 6. 2. Functionalities of Computer • A computer is an electronic device. • It operating under the control of instructions stored in its own memory. • It can accept data (input) • It process the data according to specified rules (process) • It produce results (output) and • It store the results (storage) for future use. • Generally, the term is used to describe a collection of electric, electronic, and mechanical components known as hardware. 1/7/2021 Introduction to Computers 6
  7. 7. 2. Functionalities of Computer • If we look at it in a very broad sense, any digital computer carries out the following five functions: – Step 1: Takes data as input. – Step 2: Stores the data/instructions in its memory and uses them as required. – Step 3: Processes the data and converts it into useful information. – Step 4: Generates the output. – Step 5: Controls all the above four steps. 1/7/2021 Introduction to Computers 7
  8. 8. 3. Characteristics of Computer 1/7/2021 Introduction to Computers 8 • Speed • Accuracy • Diligence • Versatility • Storage capacity • Reliability • Automation • Reduction in Paper work and Cost
  9. 9. Speed • Computers work at an incredible speed. • A powerful computer is capable of performing about 3- 4 million simple instructions per second. • It is capable of performing calculation of very large amount of data. • The computer has units of speed in microsecond, nanosecond, and even the picosecond. • It can perform millions of calculations in a few seconds as compared to man who will spend many months to perform the same task. 1/7/2021 Introduction to Computers 9
  10. 10. Accuracy • In addition to being fast, computers are also accurate. • Computers perform all jobs with 100% accuracy provided that the input is correct. • The calculations are 100% error free. • Errors that may occur can almost always be attributed to human error (inaccurate data, poorly designed system or faulty instructions/programs written by the programmer) 1/7/2021 Introduction to Computers 10
  11. 11. Diligence • Unlike human beings, computers are highly consistent. • They do not suffer from human traits of boredom and tiredness resulting in lack of concentration. • Computers, therefore, are better than human beings in performing voluminous and repetitive jobs. • It can work continuously without any error and boredom. • It can perform repeated tasks with the same speed and accuracy. 1/7/2021 Introduction to Computers 11
  12. 12. Versatility • Computers are versatile machines and are capable of performing any task as long as it can be broken down into a series of logical steps. • A computer is very flexible in performing the jobs to be done. • Computer can be used to solve the problems related to various fields. • At one instance, it may be solving a complex scientific problem and the very next moment it may be playing a card game. • The presence of computers can be seen in almost every sphere – Railway/Air reservation, Banks, Hotels, Weather forecasting and many more. 1/7/2021 Introduction to Computers 12
  13. 13. Storage Capacity • Today’s computers can store large volumes of data. • A piece of information once recorded (or stored) in the computer, can never be forgotten and can be retrieved almost instantaneously. • Memory is a very important characteristic of computers. • A computer has much more storage capacity than human beings. • It can store any type of data such as images, videos, text, audio, etc. 1/7/2021 Introduction to Computers 13
  14. 14. 4. Cons of Computer • No I.Q (Intelligence Quotient) – A computer is a machine that has no intelligence to perform any task. – Each instruction has to be given to the computer. – A computer cannot take any decision on its own. • No Feeling – Computers have no feelings or emotions. – It cannot make judgment based on feeling, taste, experience, and knowledge unlike humans. • Dependency – It functions as per the user’s instruction, thus it is fully dependent on humans. • Environment – The operating environment of the computer should be dust free and suitable. 1/7/2021 Introduction to Computers 14
  15. 15. 5. Uses of Computer • Scientific, Engineering and Research • Business • Marketing • Medicine • Information Technology • Education • Banking and Insurance • Healthcare • Engineering Design • Military • Communication • Government 1/7/2021 Introduction to Computers 15
  16. 16. 6. Types of Computer 1/7/2021 Introduction to Computers 16 Type Specifications PC (Personal Computer) It is a single user computer system having moderately powerful microprocessor. Workstation It is also a single user computer system, similar to personal computer however has a more powerful microprocessor Mini Computer It is a multi-user computer system, capable of supporting hundreds of users simultaneously. Main Frame It is a multi-user computer system, capable of supporting hundreds of users simultaneously. Software technology is different from minicomputer. Supercomputer It is an extremely fast computer, which can execute hundreds of millions of instructions per second. For example, weather forecasting, scientific simulations, (animated) graphics, fluid dynamic calculations, nuclear energy research, electronic design, and analysis of geological data (e.g. in petrochemical prospecting).
  17. 17. 7. Generation of Computer 1/7/2021 Introduction to Computers 17 Generation Description First Generation i. The period of first generation: 1946-1959. ii. Vacuum tube based. Second Generation i. The period of second generation: 1959-1965. ii. Transistor based. Third Generation i. The period of third generation: 1965-1971. ii. Integrated Circuit based. Fourth Generation i. The period of fourth generation: 1971-1980. ii. VLSI microprocessor based. Fifth Generation i. The period of fifth generation: 1980- onwards. ii. ULSI microprocessor based.
  18. 18. 8. Functional Units of Computer 1/7/2021 Introduction to Computers 18
  19. 19. 8. Functional Units of Computer 1/7/2021 Introduction to Computers 19 Operation Description Take Input  The process of entering data and instructions into the computer system Store Data  Saving data and instructions so that they are available for processing as and when required. Processing Data  Performing arithmetic, and logical operations on data in order to convert them into useful information. Output Information  The process of producing useful information or results for the user, such as a printed report or visual display. Control the workflow  Directs the manner and sequence in which all of the above operations are performed.
  20. 20. 9. Hardware and Software • Hardware – Hardware represents the physical and tangible components of a computer. – i.e. the components that can be seen and touched. • Examples of Hardware are the following: – Input devices: keyboard, mouse, etc. – Output devices: printer, monitor, etc. – Secondary storage devices: Hard disk, CD, DVD, etc. – Internal components: CPU, motherboard, RAM, etc 1/7/2021 Introduction to Computers 20
  21. 21. 9. Hardware and Software • Software – Software is a set of programs, which is designed to perform a well-defined function. – A program is a sequence of instructions written to solve a particular problem. • There are two types of software: – System Software – Application Software 1/7/2021 Introduction to Computers 21
  22. 22. System Software • The system software is a collection of programs designed to operate, control, and extend the processing capabilities of the computer itself. • System software is generally prepared by the computer manufacturers. • These software products comprise of programs written in low-level languages, which interact with the hardware at a very basic level. • System software serves as the interface between the hardware and the end users. • Some examples of system software are – Operating System – Compilers – Interpreter – Assemblers, etc. 1/7/2021 Introduction to Computers 22
  23. 23. Application Software • Application software products are designed to satisfy a particular need of a particular environment. • All software applications prepared in the computer lab can come under the category of Application software. • Application software may consist of a single program, such as Microsoft's notepad for writing and editing a simple text. • It may also consist of a collection of programs, often called a software package, which work together to accomplish a task, such as a spreadsheet package. (MS Office) • Examples of Application software are the following: – Payroll Software – Student Record Software – Inventory Management Software – Income Tax Software – Railways Reservation Software – Microsoft Office Suite Software 1/7/2021 Introduction to Computers 23
  24. 24. Thank you 1/7/2021 Introduction to Computers 24
  25. 25. Inside of Computer By Mr.S.Selvaraj Asst. Professor(SRG) / CSE Kongu Engineering College
  26. 26. Contents • Hardware Component of Computer • Motherboard Structure • Interfaces – Input/Output Interface – Processor Interface – Main Memory Interface – Secondary Memory Interface – Other Interfaces Introduction to Problem Solving Techniques1/7/2021 26
  27. 27. 1. Hardware Components of Computer Introduction to Problem Solving Techniques1/7/2021 27
  28. 28. 1/7/2021 Introduction to Problem Solving Techniques 28
  29. 29. Motherboard Structure 1/7/2021 Introduction to Problem Solving Techniques 29
  30. 30. RAM 1/7/2021 Introduction to Problem Solving Techniques 30
  31. 31. ROM 1/7/2021 Introduction to Problem Solving Techniques 31
  32. 32. Hard Disk 1/7/2021 Introduction to Problem Solving Techniques 32
  33. 33. Functional Units of Computer 1/7/2021 Introduction to Problem Solving Techniques 33
  34. 34. Basic Organization of Computer 1/7/2021 Introduction to Problem Solving Techniques 34
  35. 35. Thank you Introduction to Problem Solving Techniques1/7/2021 35
  36. 36. Introduction to Problem Solving Techniques By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  37. 37. Contents • Introduction • Steps involved in Problem Solving • Problem Solving Techniques – Algorithm – Flowchart – Pseudo Code – Program Introduction to Problem Solving Techniques1/7/2021 37
  38. 38. 1. Introduction • A computer is a very powerful and versatile machine capable of performing a multitude of different tasks, yet it has no intelligence or thinking power. • The intelligence Quotient (I.Q) of a computer is zero. • This places responsibility on the user to instruct the computer in a correct and precise manner, so that the machine is able to perform the required job in a proper way. • A wrong or ambiguous instruction may sometimes prove disastrous. Introduction to Problem Solving Techniques1/7/2021 38
  39. 39. 1. Introduction • In order to instruct a computer correctly, the user must have clear understanding of the problem to be solved. • A part from this the user should be able to develop a method, in the form of series of sequential steps, to solve it. • Once the problem is well-defined and a method of solving it is developed, then instructing the computer to solve the problem becomes relatively easier task. • Thus, before attempt to write a computer program to solve a given problem. – It is necessary to formulate or define the problem in a precise manner. – Once the problem is defined, the steps required to solve it, must be stated clearly in the required order. Introduction to Problem Solving Techniques1/7/2021 39
  40. 40. 2. Steps involved in Problem Solving • A computer cannot solve a problem on its own. • One has to provide step by step solutions of the problem to the computer. • In fact, the task of problem solving is not that of the computer. It is the programmer who has to write down the solution to the problem in terms of simple operations which the computer can understand and execute. • In order to solve a problem by the computer, one has to pass though certain stages or steps. • They are – 1.Understanding the problem – 2. Analyzing the problem – 3.Developing the solution – 4.Coding and implementation. Introduction to Problem Solving Techniques1/7/2021 40
  41. 41. 2.Steps involved in Problem Solving • 1.Understanding the problem: – Here we try to understand the problem to be solved in totally. – Before with the next stage or step, we should be absolutely sure about the objectives of the given problem. • 2.Analyzing the problem: – After understanding thoroughly the problem to be solved, we look different ways of solving the problem and evaluate each of these methods. – The idea here is to search an appropriate solution to the problem under consideration. – The end result of this stage is a broad overview of the sequence of operations that are to be carries out to solve the given problem. Introduction to Problem Solving Techniques1/7/2021 41
  42. 42. 2.Steps involved in Problem Solving • 3. Developing the solution: – Here the overview of the sequence of operations that was the result of analysis stage is expanded to form a detailed step by step solution to the problem under consideration. • 4. Coding and implementation: – The last stage of the problem solving is the conversion of the detailed sequence of operations in to a language that the computer can understand. – Here each step is converted to its equivalent instruction or instructions in the computer language that has been chosen for the implantation. Introduction to Problem Solving Techniques1/7/2021 42
  43. 43. 3. Problem Solving Techniques • Algorithm • Flowchart • Pseudo Code • Program Introduction to Problem Solving Techniques1/7/2021 43
  44. 44. 3.1 Algorithm Introduction to Problem Solving Techniques • A set of sequential steps usually written in Ordinary Language to solve a given problem is called Algorithm. • An algorithm can be defined as “a complete, unambiguous, finite number of logical steps for solving a specific problem” • It may be possible to solve to problem in more than one ways, resulting in more than one algorithm. • The choice of various algorithms depends on the factors like reliability, accuracy and easy to modify. • The most important factor in the choice of algorithm is the time requirement to execute it, after writing code in High-level language with the help of a computer. • The algorithm which will need the least time when executed is considered the best. 1/7/2021 44
  45. 45. 3.1 Steps in Algorithm Development Introduction to Problem Solving Techniques • Step1. Identification of input: – For an algorithm, there are quantities to be supplied called input and these are fed externally. – The input is to be indentified first for any specified problem. • Step2: Identification of output: – From an algorithm, at least one quantity is produced, called output for any specified problem. • Step3 : Identification the processing operations : – All the calculations to be performed in order to lead to output from the input are to be identified in an orderly manner. 1/7/2021 45
  46. 46. 3.1 Steps in Algorithm Development • Step4 : Processing Definiteness : – The instructions composing the algorithm must be clear and there should not be any ambiguity in them. • Step5 : Processing Finiteness : – If we go through the algorithm, then for all cases, the algorithm should terminate after a finite number of steps. • Step6 : Possessing Effectiveness : – The instructions in the algorithm must be sufficiently basic and in practice they can be carries out easily. Introduction to Problem Solving Techniques1/7/2021 46
  47. 47. Example for Algorithm • Example1: • Suppose we want to find the average of three numbers, the algorithm is as follows: – Step 1: Start the program – Step 2: Read the numbers a, b, c – Step 3: Compute the sum of a, b and c – Step 4: Divide the sum by 3 – Step 5: Store the result in variable d – Step 6: Print the value of d – Step 7: End of the program Introduction to Problem Solving Techniques1/7/2021 47
  48. 48. 3.2 Flowchart • A flow chart is a step by step diagrammatic representation of the logic paths to solve a given problem. • Or • A flowchart is visual or graphical representation of an algorithm. • The flowcharts are pictorial representation of the methods to be used to solve a given problem and help a great deal to analyze the problem and plan its solution in a systematic and orderly manner. • A flowchart when translated into a proper computer language, results in a complete program. Introduction to Problem Solving Techniques1/7/2021 48
  49. 49. Advantages of Flowcharts • The flowchart shows the logic of a problem displayed in pictorial fashion which felicitates easier checking of an algorithm. • The Flowchart is good means of communication to other users. It is also a compact means of recording an algorithm solution to a problem. • The flowchart allows the problem solver to break the problem into parts. These parts can be connected to make master chart. • The flowchart is a permanent record of the solution which can be consulted at a later time. Introduction to Problem Solving Techniques1/7/2021 49
  50. 50. Difference b/w Algorithm and Flowcharts Introduction to Problem Solving Techniques Algorithm Flowcharts A method of representing the step- by-step logical procedure for solving a problem Flowchart is diagrammatic representation of an algorithm. It is constructed using different types of boxes and symbols. It contains step-by-step English descriptions, each step representing a particular operation leading to solution of problem The flowchart employs a series of blocks and arrows, each of which represents a particular step in an algorithm These are particularly useful for small problems These are useful for detailed representations of complicated programs For complex programs, algorithms prove to be Inadequate For complex programs, Flowcharts prove to be adequate 1/7/2021 50
  51. 51. Symbols used in Flowcharts Introduction to Problem Solving Techniques Symbol Name Symbol Description Oval Rectangle with rounded sides is used to indicate either START/STOP of the program. .. Input and output indicators Parallelograms are used to represent input and output operations. Statements like INPUT, READ and PRINT are represented in these Parallelograms. Process Indicators Rectangle is used to indicate any set of processing operation such as for storing arithmetic operations. Decision Makers The diamond is used for indicating the step of decision making and therefore known as decision box. Decision boxes are used to test the conditions or ask questions and depending upon the answers, the appropriate actions are taken by the computer. 1/7/2021 51
  52. 52. Symbols used in Flowcharts Introduction to Problem Solving Techniques Symbol Name Symbol Description Flow Lines Flow lines indicate the direction being followed in the flowchart. In a Flowchart, every line must have an arrow on it to indicate the direction. The arrows may be in any direction On- Page connectors Circles are used to join the different parts of a flowchart and these circles are called on-page connectors. The uses of these connectors give a neat shape to the flowcharts. Ina complicated problems, a flowchart may run in to several pages. The parts of the flowchart on different pages are to be joined with each other. The parts to be joined are indicated by the circle. Off-page connectors This connector represents a break in the path of flowchart which is too large to fit on a single page. It is similar to on-page connector. The connector symbol marks where the algorithm ends on the first page and where it continues on the second 1/7/2021 52
  53. 53. Example – Flowchart Introduction to Problem Solving Techniques • Example: Draw a flowchart to perform average of three numbers. 1/7/2021 53
  54. 54. 3.3 Pseudo Code • The Pseudo code is neither an algorithm nor a program. • It is an abstract form of a program. • It consists of English like statements which perform the specific operations. • It is defined for an algorithm. • It does not use any graphical representation. • In pseudo code, the program is represented in terms of words and phrases, but the syntax of program is not strictly followed. Introduction to Problem Solving Techniques1/7/2021 54
  55. 55. Example – Pseudo Code • Example: Write a pseudo code to perform average of three numbers. 1. Begin 2. Read n1, n2, n3 3. Sum = n1 + n2 + n3 4. Avg = Sum/3 5. Print Avg 6. End Introduction to Problem Solving Techniques1/7/2021 55
  56. 56. 3.4 Program • Program consists of a series of instructions that a computer processes to perform, the required operation. • Or • A computer program is a collection of instructions that can be executed by a computer to perform a specific task. • A computer program is usually written by a computer programmer in a programming language. • From the program in its human-readable form of source code, a compiler or assembler can derive machine code —a form consisting of instructions that the computer can directly execute. • A collection of computer programs, libraries, and related data are referred to as software. • Computer programs may be categorized along functional lines, such as application software and system software. Introduction to Problem Solving Techniques1/7/2021 56
  57. 57. Example - Program • Example: Write a C program to perform average of five numbers. Introduction to Problem Solving Techniques1/7/2021 57
  58. 58. Thank you Introduction to Problem Solving Techniques1/7/2021 58
  59. 59. Compound Interest (CI) 1/7/2021 Introduction to Problem Solving Techniques 59 Five min time .. work out and tell the answer in chat box
  60. 60. Introduction to Raptor Tool By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  61. 61. RAPTOR Tool • RAPTOR(Rapid Algorithmic Prototyping Tool for Ordered Reasoning) is a free graphical authoring tool created by – Martin C. Carlisle, – Terry Wilson, – Jeff Humphries and – Jason Moore. • Designed specifically to help students visualize their algorithms and avoid syntactic baggage. • Students can create flow-chart for a particular program. • Raptor tool will generate code for it in various programming languages, such as C, C++, Java and so on. 1/7/2021 Introduction to Raptor Tool 61
  62. 62. Symbols in RAPTOR • Raptor has 6 types of symbols, each of which represents a unique kind of instruction. • They are : – Assignment – Call – Input – Output – Selection and – Loop 1/7/2021 Introduction to Raptor Tool 62
  63. 63. RAPTOR Program Structure 1/7/2021 Introduction to Raptor Tool 63 • A RAPTOR program consists of connected symbols that represent actions to be executed. • The arrows that connect the symbols determine the order in which the actions are performed. • The execution of a RAPTOR program begins at the Start symbol and goes along the arrows to execute the program. • The program stops executing when the End symbol is reached.
  64. 64. RAPTOR Tool 1/7/2021 Introduction to Raptor Tool 64
  65. 65. Sample RAPTOR Flowchart 1/7/2021 Introduction to Raptor Tool 65
  66. 66. Sample RAPTOR Program • With the help of Generate option, the generated C++ code for the above flow chart is: 1/7/2021 Introduction to Raptor Tool 66
  67. 67. C++ code generated from RAPTOR tool • // CPP program for illustrating RAPTOR • #include <iostream> • #include <string> • using namespace std; • int main() • { • string raptor_prompt_variable_zzyz; • float m; • raptor_prompt_variable_zzyz ="enter the marks"; • cout << raptor_prompt_variable_zzyz << endl; • cin >> m; • if (m>=90) • { • cout << "The grade is A" << endl; } • else • { • if (m>=80) • { • cout << "The grade is B" << endl; } • else • { • if (m>=60) • { • cout << "The grade is C" << endl; } • else • { • cout << "The grade is D" << endl; } • } • } • return 0; • } 1/7/2021 Introduction to Raptor Tool 67
  68. 68. Thank you Introduction to Raptor Tool1/7/2021 68
  69. 69. Structuring the logic: Sequential By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  70. 70. Sequencing • Sequencing is represented by – rectangular boxes for data processing and – a parallelogram for input/output activities. 1/7/2021 Structuring the logic: Sequential 70
  71. 71. Sequential Flow Chart 1/7/2021 Structuring the logic: Sequential 71
  72. 72. Sample Problems • Find Simple Interest Rate and Compound Interest Rate. • Fin Sum and Average of Three Numbers. • Find Engineering Cut-off mark. • Find area of geometric shapes. • Fruit Stall Problem 1/7/2021 Structuring the logic: Sequential 72
  73. 73. Formula to calculate area of geometric shapes 1/7/2021 Structuring the logic: Sequential 73
  74. 74. Fruit Stall Problem 1 1/7/2021 Structuring the logic: Sequential 74
  75. 75. Fruit Stall Problem 2 1/7/2021 Structuring the logic: Sequential 75
  76. 76. Fruit Stall Problem 3 1/7/2021 Structuring the logic: Sequential 76
  77. 77. Thank you Structuring the logic: Sequential1/7/2021 77
  78. 78. Structuring the logic: Selection By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  79. 79. Selection / Decision Making • Decision making is represented by the diamond which accepts input from the top corner. • For two-way decision making (say, for representing the condition x > 5), two arrows emanate from the bottom- and right-corner of this diamond. • Example shows the flowchart for determining whether a number is even or odd. • The % (modulus) operator is used to compute the remainder of a division, so n % 2 evaluates to 0 or 1, while n % 3 evaluates to 0, 1 or 2. • Complex decisions that need multiple IF statements are represented by connecting multiple diamonds. 1/7/2021 Structuring the logic: Selection 79
  80. 80. Example 1/7/2021 Structuring the logic: Selection 80
  81. 81. Sample Problems • check whether the person is eligible to vote or not. • Print the student result as whether PASS or FAIL. • Print the Grade Points for the Subject Mark. • Fruit Stall Problem. • Traffic Light Problem. • Energy Level Problem. 1/7/2021 Structuring the logic: Selection 81
  82. 82. KEC Grading System 1/7/2021 Structuring the logic: Selection 82
  83. 83. Fruit Stall Problem 1/7/2021 Structuring the logic: Selection 83
  84. 84. Traffic Light Problem 1/7/2021 Structuring the logic: Selection 84
  85. 85. Energy Level Problem 1/7/2021 Structuring the logic: Selection 85
  86. 86. Thank you Structuring the logic: Selection1/7/2021 86
  87. 87. Structuring the logic: Repetition By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  88. 88. Repetition • There is no standard symbol for representing repetition; • a loop structure created by combining sequential and decision-making symbols repeatedly executes a set of instructions. • Because the loop has to eventually terminate, a conditional check must be made either at the beginning or end of the iterative process. • The most commonly used repetitive construct is the while statement. • Some languages also support variants like the for, until, do-while and repeat constructs 1/7/2021 Structuring the logic: Repetition 88
  89. 89. Sample – Factorial Calcualtion 1/7/2021 Structuring the logic: Repetition 89
  90. 90. Problem 1 • Print sum of any ‘n’ numbers. • Sample Output: Enter the n value: 5 Enter 1 st Number : 15 Enter 2 nd Number : 20 Enter 3 rd Number : 25 Enter 4 th Number : 30 Enter 5 th Number : 20 Sum of the 5 Numbers are : 100 1/7/2021 Structuring the logic: Repetition 90
  91. 91. Problem 2 • Find the factorial of an number. • Sample Output: Enter the value: 5 Factorial of 5 is : 120 1/7/2021 Structuring the logic: Repetition 91
  92. 92. Problem 3 • Generate a table that displays a list of numbers and the square of those numbers. • Ask the user how many numbers to include in the list • Display the sum of all of the squares we compute. • Sample Output: How many Numbers should be in the table? 6 Number Square ================= 1 1 2 4 3 9 4 16 5 25 6 36 The sum of these squares is 91. 1/7/2021 Structuring the logic: Repetition 92
  93. 93. Problem 4 • Calculate TN engineering cut-off mark for ‘N’ students. • Sample Output: Enter the number of students to calculate cut-off mark: 5 ================================================ Student Name Maths Phy Chem Cut-off ================================================ Kumar 80 60 60 140 Raj 90 90 90 180 Vidhya 100 100 100 200 Williams 50 80 65 122.50 Mohammed 60 100 75 147.50 1/7/2021 Structuring the logic: Repetition 93
  94. 94. Problem 5 • Generate the first N terms of Fibonacci sequence numbers. • Sample output: Enter the N value: 10 First 10 terms of Fibonacci numbers are: 0 1 1 2 3 5 8 13 21 34 1/7/2021 Structuring the logic: Repetition 94
  95. 95. Thank you Structuring the logic: Repetition1/7/2021 95
  96. 96. Case Studies on Problem Solving By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  97. 97. Case Study 1: Exchanging the values of two variables 1/7/2021 Case Studies on Problem Solving 97
  98. 98. 1/7/2021 Case Studies on Problem Solving 98
  99. 99. 1/7/2021 Case Studies on Problem Solving 99
  100. 100. 1/7/2021 Case Studies on Problem Solving 100
  101. 101. Case Study 1: Algorithm 1/7/2021 Case Studies on Problem Solving 101
  102. 102. Case Study 1: Pseudo Code 1/7/2021 Case Studies on Problem Solving 102
  103. 103. Case Study 1: Flowchart 1/7/2021 Case Studies on Problem Solving 103
  104. 104. Is it possible to solve the above case study by without using temporary variable ? 1/7/2021 Case Studies on Problem Solving 104
  105. 105. 1/7/2021 Case Studies on Problem Solving 105
  106. 106. 1/7/2021 Case Studies on Problem Solving 106
  107. 107. Case Study 2: Finding the maximum of N Numbers 1/7/2021 Case Studies on Problem Solving 107
  108. 108. 1/7/2021 Case Studies on Problem Solving 108
  109. 109. Case Study 3: Reversing the Digits of an integer number 1/7/2021 Case Studies on Problem Solving 109
  110. 110. 1/7/2021 Case Studies on Problem Solving 110
  111. 111. Sample Output • Enter the Number to reverse: 1562 • The reversed number is : 2651 1/7/2021 Case Studies on Problem Solving 111
  112. 112. Thank you Case Studies on Problem Solving1/7/2021 112
  113. 113. Programming Methodologies By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  114. 114. Introduction to Programming • Programs should also be designed to be reusable. • Most modern languages are procedural. – They enable the execution of a section of code by invoking the name assigned to the section. – They also have separate names for these sections— like routines, subroutines, procedures or functions. • Another set of languages (like C++ and Java) added the object flavor to change the programming paradigm altogether. 1/7/2021 Case Studies on Problem Solving 114
  115. 115. Programming Methodologies • These features allow the division of code into separate modules using the following programming methodologies to choose from: – Top-down programming – Bottom-up programming – Object-oriented programming 1/7/2021 Case Studies on Problem Solving 115
  116. 116. Top-down programming • A problem can be approached from the top to first visualize the “big picture” before breaking it up into separate components (top-down programming). • C programming supports this approach for developing projects. It is always good idea that decomposing solution into modules in a hierarchical manner. • The basic task of a top-down approach is to divide the problem into tasks and then divide tasks into smaller sub-tasks and so on. • In this approach, first we develop the main module and then the next level modules are developed. • This procedure is continued until all the modules are developed. 1/7/2021 Case Studies on Problem Solving 116
  117. 117. Top-down programming 1/7/2021 Case Studies on Problem Solving 117
  118. 118. Advantages of top-down approach • In this approach, first, we develop and test most important module. • This approach is easy to see the progress of the project by developer or customer. • Using this approach, we can utilize computer resources in a proper manner according to the project. • Testing and debugging is easier and efficient. • In this approach, project implementation is smoother and shorter. • This approach is good for detecting and correcting time delays. 1/7/2021 Case Studies on Problem Solving 118
  119. 119. Bottom-up programming • The individual components can be designed first without fully knowing the big picture. The components are later integrated to form the complete system (bottom-up programming). 1/7/2021 Case Studies on Problem Solving 119
  120. 120. Bottom-up programming 1/7/2021 Case Studies on Problem Solving 120
  121. 121. Object-oriented programming • The problem can be conceived as a collection of objects where each object encapsulates both data and the method used to access the data (object-oriented programming—OOP). • Advantages: – No separate instructions are needed because these objects encapsulate both data and instructions (called methods) to access and manipulate the data. – objects are reusable and easily interact with one another. – object-oriented programming is used for large and complex projects. 1/7/2021 Case Studies on Problem Solving 121
  122. 122. Object-oriented programming 1/7/2021 Case Studies on Problem Solving 122
  123. 123. Thank you Case Studies on Problem Solving1/7/2021 123
  124. 124. Structured Programming By Mr.S.Selvaraj Asst. Professor (SRG) / CSE Kongu Engineering College
  125. 125. Structured Programming • Structured programming strives to achieve clarity, faster development times and easy maintainability of programs. • It is an offshoot of procedural programming but goes beyond the use of subroutines or functions to create modular programs. • Structured programs use – control blocks (a group of statements that are treated as a single statement) and – loops (the repetition of one or more statements). • These constructs are meant to replace the age-old GOTO statement whose use has now been deprecated (somewhat questionably though). 1/7/2021 Structured Programming 125
  126. 126. Structured Programming • The foundations of structured programming can be traced back to the mathematicians Bohm and Jacopini. • They proved in their structure theorem that any computing problem can be solved by using only the following constructs: – Sequencing (the execution of statements in sequence). – Decision making (selection from among alternatives). – Repetition (running one or more statements in a loop). 1/7/2021 Structured Programming 126
  127. 127. Structured Programming – Control Structures 1/7/2021 Structured Programming 127 • Following the structured program theorem, all programs are seen as composed of control structures: – "Sequence"; ordered statements or subroutines executed in sequence. – "Selection"; one or a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else..endif.
  128. 128. Structured Programming – Control Structures • "Iteration"; a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. – This is usually expressed with keywords such as while, repeat, for or do..until. Often it is recommended that each loop should only have one entry point • "Recursion"; a statement is executed by repeatedly calling itself until termination conditions are met. – While similar in practice to iterative loops, recursive loops may be more computationally efficient, and are implemented differently as a cascading stack. 1/7/2021 Structured Programming 128
  129. 129. Structured Programming Languages • The languages that support Structured programming approach are: – C – C++ – Java – C# 1/7/2021 Structured Programming 129
  130. 130. Advantages of Structured Programming • Easier to read and understand • User Friendly • Easier to Maintain • Mainly problem based instead of being machine based • Development is easier as it requires less effort and time • Easier to Debug • Machine-Independent, mostly. 1/7/2021 Structured Programming 130
  131. 131. Thank you Structured Programming1/7/2021 131

×