Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Problem-solving is the process of identifying a problem, creating an algorithm to solve the given problem, and finally implementing the algorithm to develop a computer program. An algorithm is a process or set of rules to be followed while performing calculations or other problem-solving operations.
Typology: Study notes
1 / 6
Algorithms can be constructed from basic building blocks namely, sequence, selection and iteration.
Statement is a single action in a computer. In a computer statements might include some of the following actions input data-information given to the program process data-perform operation on a given input output data-processed result
Transition from one process to another process under specified condition with in a time is called state.
The process of executing the individual statements in a given order is called control flow. The control can be executed in three ways
If the conditional test is true, one part of the program will be executed, otherwise it will execute the other part of the program. Example Write an algorithm to check whether he is eligible to vote? Step 1: Start Step 2: Get age Step 3: if age >= 18 print “Eligible to vote” Step 4: else print “Not eligible to vote” Step 6: Stop
Iteration: In some programs, certain set of statements are executed again and again based upon conditional test. i.e. executed more than one time. This type of execution is called looping or iteration. Example Write an algorithm to print all natural numbers up to n Step 1: Start Step 2: get n value. Step 3: initialize i= Step 4: if (i<=n) go to step 5 else go to step 7 Step 5: Print i value and increment i value by 1 Step 6: go to step 4 Step 7: Stop
Function is a sub program which consists of block of code(set of instructions) that performs a particular task. For complex problems, the problem is been divided into smaller and simpler tasks during algorithm design.
Benefits of Using Functions Reduction in line of code code reuse Better readability Information hiding Easy to debug and test Improved maintainability Example: Algorithm for addition of two numbers using function Main function() Step 1: Start Step 2: Call the function add() Step 3: Stop sub function add() Step 1: Function start Step 2: Get a, b Values Step 3: add c=a+b Step 4: Print c Step 5: Return