🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

PPS-Unit-1.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

21CSS101J – PROGRAMMING FOR PROBLEM SOLVING UNIT-1 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 2 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST...

21CSS101J – PROGRAMMING FOR PROBLEM SOLVING UNIT-1 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 2 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 3 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 4 Evolution of programming Languages 2010- 2019 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST Programming for Problem Solving What is Problem Solving? Problem solving is a general way to write solutions in an orderly way to find solutions for problems. This includes analyzing the potential causes of a problem and finding action plan / solutions to the problem. Everyone uses problem-solving skills both in their personal and A good Problem Solving methods involves a step by step procedure in giving solutions Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 1 Programming for Problem Solving Not all problems are solvable! A problem is solvable only when there exist a procedure / algorithm / steps that can be followed to solve it with definite boundaries. A problem is unsolvable if there is no definite procedure or boundaries (where to start and stop) on the problem. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 2 What is Problem Solving Not all problems are solvable! Number Scrabble Problem: Number Scrabble is a game which is played with a set of numbers from 1 to 9. Every player picks a number from the list in their turn. The number once taken cannot be taken again. When a player picks and arranges the number in a way the total horizontal, vertical or diagonal sums to 15, the player wins. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 3 What is Problem Solving Number Scrabble Problem: As an example game between player A and player B: A picks 9. B picks 8. A picks 2. B has no choice but to pick 4 (otherwise, A could get 9+2+4=15). A has no choice but to pick 3 (otherwise, B could get 8+4+3=15). B picks 6, and thereby confirms to win by either picking 1 (8+6+1=15) or 5 (4+6+5=15). Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 4 AI based searching problem AI Enabled Path Finding Problem D S Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 5 Programming for Problem Solving A computer can solve comprehensive problems. Assume a textile manufacturer who saw his sales declining. He computerized the operational process and observed the production and sales data. He applied invoicing and process management The sales increased with support of inventory software. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 6 Programming for Problem Solving A computer won't solve a poorly written or a big comprehensive problems. Assume that one of your friend is depressed and not even ready to speak with you. Can you give a solution by yourself? Or Can you find a solution by programming a computer? No! Cannot find solutions for an undefined problem. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 7 1.3 Writing algorithms & Pseudo code Algorithm: Algorithm means a set of rules that must be followed when solving a particular problem. Algorithm consists of the specific steps or the methods that have to be followed in order to solve a problem. Programming = Letting the computer to know how to solve a problem Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 8 Writing algorithm to find the sum and average of three numbers Step 1: Start Step 2 :Read the three number suppose "a","b","c" form the user. Step 3: Declared a variable "sum" and "Avg". Step 4 : sum=a+b+c; Step 5: Avg=sum/3 Step 6:Display "sum " and "Avg". Step 7 :End. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 1 9 Writing algorithm to find the average of 20 numbers 1. Sum=0 2. For 20 numbers 3. Repeat 4. Get number 5. Add the number with the current sum 6. End 7. Result= sum/20 Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 2 0 Pseudo-Code In C programming language, it becomes mandatory to follow syntax while executing the program, and it becomes challenging to understand the logic of the complex program. Therefore, to understand the program logic in a better way and to solve the complex problem, we must write it in pseudocode, which is written in simple English that makes it easy to understand Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 2 1 Pseudo-Code What Is Pseudo-Code in C? The pseudocode in C is an informal way of writing a program for better human understanding. It is written in simple English, making the complex program easier to understand. Pseudocode cannot be compiled or interpreted. It doesn't follow the programming language's syntax; it is thus written in pseudocode so that any programmers or non-programmers can easily understand it. Dr. R. Mohandas, Asst. Prof., CINTEL, SRMIST 2 2 Pseudo-Code Consider the following source code example: int n = 10 for( i=0;i

Use Quizgecko on...
Browser
Browser