Cs 1114 - lecture-2


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Cs 1114 - lecture-2

  1. 1. Programming Fundamentals
  2. 2. This Course Problem Solving Using Computers Implementing the Solution using a Programming Language 1 2 The first part is mostly ignored which leads to poor programming skills Programming Fundamentals | Lecture-2
  3. 3. 1
  4. 4. Steps in Problem Solving Define the Problem Design the Solution 1 2 Programming Fundamentals | Lecture-2
  5. 5. 1. Define the Problem <ul><li>After careful reading, the problem should be divided into three separate components </li></ul><ul><ul><li>Input </li></ul></ul><ul><ul><ul><li>Data provided to the problem </li></ul></ul></ul><ul><ul><li>Output </li></ul></ul><ul><ul><ul><li>What is required from the solution </li></ul></ul></ul><ul><ul><li>Processing </li></ul></ul><ul><ul><ul><li>List of actions needed to produce the required output </li></ul></ul></ul>Programming Fundamentals | Lecture-2
  6. 6. 2. Design the Solution Solution of a Problem in your mind Solution in terms of no. of steps Transform There are more than 1 ways to do that but we will use a graphical approach which will involve usage of Geometrical Shapes to represent different kinds of steps in a solution Programming Fundamentals | Lecture-2
  7. 7. Example-1 Programming Fundamentals | Lecture-2
  8. 8. Step-1: Define the Problem Programming Fundamentals | Lecture-2 Problem : Find the sum of two numbers Input Output Processing Number1 Sum Add Numbers Together Number2
  9. 9. Step-2: Design the Solution <ul><li>Start by drawing a “Start” symbol </li></ul><ul><li>Show a symbol for Input </li></ul><ul><li>Show process symbol(s) for processing </li></ul><ul><ul><li>There can be more than 1 such steps depending on the complexity of the problem </li></ul></ul><ul><li>Show a symbol for Output </li></ul><ul><li>Finish by drawing a “Stop” Symbol </li></ul>Programming Fundamentals | Lecture-2
  10. 10. Step-2: Design the Solution Programming Fundamentals | Lecture-2 START READ number1, number2 sum = number1 + number2 DISPLAY sum STOP
  11. 11. Legend Programming Fundamentals | Lecture-2 Symbol Meaning Terminal Symbol (Oval) : indicates the beginning and ending of a program Input-Output Symbol (Parallelogram): shows an input or an output operation Process Symbol (Rectangle): shows an instruction other than input or output
  12. 12. Other Simple Examples <ul><li>Find sum of three numbers </li></ul><ul><li>Division, multiplication, subtraction of two/three numbers </li></ul><ul><li>Find Average of two numbers </li></ul><ul><li>Find square of a number </li></ul><ul><li>Find acceleration for a given velocity and time </li></ul><ul><li>Find Velocity </li></ul>Programming Fundamentals | Lecture-2
  13. 13. Average of Two Numbers Programming Fundamentals | Lecture-2 START READ number1, number2 sum = number1 + number2 DISPLAY average STOP average = sum / 2
  14. 14. Square of a Number Programming Fundamentals | Lecture-2 START READ number square = number * number DISPLAY square STOP
  15. 15. Acceleration Programming Fundamentals | Lecture-2 START READ v1, v2, t change = v2 – v1 DISPLAY acceleration STOP acceleration = change / t
  16. 16. Velocity Programming Fundamentals | Lecture-2 START READ d1, d2, t1, t2 positionChange = d2 – d1 DISPLAY velocity STOP timeChange = t2 – t1 velocity = postionChange / timeChange
  17. 17. Why to use Computers? <ul><li>Can do many complicated tasks at very high speeds and can store large quantities of data </li></ul><ul><li>Some Situations </li></ul><ul><ul><li>Extensive Input </li></ul></ul><ul><ul><li>Extensive output </li></ul></ul><ul><ul><li>Method of solution is too complicated to implement manually </li></ul></ul><ul><ul><li>If done manually, it takes an excessive long time to solve </li></ul></ul>
  18. 18. Tasks (to be done before next lecture) <ul><li>Calculate area of a rectangle </li></ul><ul><ul><li>area = base  height </li></ul></ul><ul><li>Find Cube of a Number </li></ul><ul><li>Calculate Marks Percentage </li></ul><ul><ul><li>(marks obtained / total marks)  100 </li></ul></ul><ul><li>Calculate Sales Tax </li></ul><ul><ul><li>amount  (tax percent / 100) </li></ul></ul><ul><li>Find “no. of minutes” and “no. of seconds” for given “no of years” </li></ul>Programming Fundamentals | Lecture-2
  19. 19. Programming Fundamentals | Lecture-2 BE READY FOR QUIZ IN NEXT LECTURE