Unit 2 Computer Fundamentals & MS-Office PDF

Document Details

GallantDenouement943

Uploaded by GallantDenouement943

Aligarh College of Engineering and Technology

Shahrukh Kamal

Tags

computer fundamentals algorithms flowcharts computer science

Summary

This document details Unit 2 of Computer Fundamentals and MS-Office, focusing on algorithms and their characteristics, with examples of flowcharts for various calculations.

Full Transcript

ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE Algorithm D...

ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE Algorithm Definition: RING AND TECHNO LOGY Definition: An algorithm is a procedure that describes a set of instructions that must be carried out in a specific order to get the desired result. An algorithm may be performed in multiple computer languages since algorithms are often designed independently of the underlying languages. A few properties of an algorithm are clarity, excellence, efficacy, and language independence. An algorithm's performance and scalability are what determine how important it is. Characteristics of an Algorithm o An algorithm needs specific input values. A number other than 0 may be provided as input to an algorithm. o An algorithm will provide one or more outputs when it is finished. o Unambiguity: An ideal algorithm has specific instructions, which implies that they should be simple and obvious. o Algorithms must be finite to function. In this context, "finiteness" refers to the requirement that an algorithm has limited instructions or instructions that can be counted. o Effectiveness: An algorithm should be sufficient since each instruction impacts the whole procedure. o An algorithm must be language-independent, which implies that its instructions must work the same no matter what language is used to implement them. Page1 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE Why is an Algorithm Needed? RING AND The following justifies your need for algorithms: TECHNO 1. Scalability LOGY Your comprehension of scalability is aided by it. It must be divided into manageable parts to rapidly examine a sizeable real-world issue. 2. Performance It can be challenging to organize the actual world into manageable pieces. It is possible to complete if a work can be divided into smaller, more manageable steps. Benefits of algorithms o It is simple to comprehend. o A solution to a problem is represented step-by-step in an algorithm. o Since the problem is divided into smaller components or steps when using an algorithm, it is simpler for the programmer to turn the algorithm into a working program. Drawbacks of Algorithm o Writing an algorithm requires a lot of time. o It can be quite challenging to comprehend complicated reasoning using algorithms. o Algorithms (imp) make it tough to display branching and looping statements. Advantages of algorithm: There are numerous blessings of designing and studying algorithms: 1. Improved efficiency: A properly designed algorithm can notably improve the performance of a program, leading to quicker execution instances and reduced resource utilization. By studying algorithms and identifying regions of inefficiency, developers can optimize the algorithm to lessen its time and space complexity. 2. Better scalability: As the size of the input information will increase, poorly designed algorithms can quickly turn out to be unmanageable, leading to slow execution times and crashes. By designing algorithms that scale well with increasing input sizes, developers can make certain that their packages stay usable while the facts they take care of grows. Page2 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE 3. Improved code exceptional: A nicely designed algorithm can result in better code first-rate RING standard, because it encourages developers to think seriously about their application's AND shape and organization. By breaking down complicated issues into smaller, extra TECHNO manageable subproblems, builders can create code that is simpler to recognize and LOGY maintain. 4. Increased innovation: By knowing how algorithms work and how they can be optimized, developers can create new and progressive solutions to complex problems. This can lead to new merchandise, services, and technologies which can have a considerable impact on the arena. 5. Competitive benefit: In industries where pace and performance are vital, having properly designed algorithms can provide an extensive competitive advantage. By optimizing algorithms to lessen expenses and enhance performance, groups can gain a facet over their competitors. Examples. Algorithm for add of two No. 1. Start 2. Input a 3. Input b 4. Set sum = a + b 5. Output sum 6. End Algorithm to Check if a Number is Natural 1. Start 2. Input n 3. If n > 0 Output "n is a natural number" Else Page3 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE Output "n is not a natural number" RING 4. End AND TECHNO LOGY Algorithm to Check if a Number is Even or Odd 1. Start 2. Input n 3. If n % 2 == 0 Output "n is an even number" Else Output "n is an odd number" 4. End Algorithm to Check if a Year is a Leap Year 1. Start 2. Input y 3. If y % 4 == 0 and (y % 100 != 0 or y % 400 == 0) Output "y is a leap year" Else Output "y is not a leap year" 4. End Algorithm to Find the Maximum of Two Numbers 1. Start 2. Input a, b 3. If a > b Output "a is the maximum" Page4 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE Else RING Output "b is the maximum" AND TECHNO 4. End LOGY Algorithm to Calculate the Factorial of a Number 1. Start 2. Input n 3. Set factorial = 1 4. For i = 1 to n Set factorial = factorial * i 5. Output factorial 6. End flowchart The Flowchart is the most widely used graphical representation of an algorithm and procedural design workflows. It uses various symbols to show the operations and decisions to be followed in a program. It flows in sequential order. Flowchart symbols: The various symbols used in Flowchart Designs are given below. Page5 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE o Terminal Symbol: In the flowchart, it is represented with the help of a circle for denoting the RING start and stop symbol. The symbol given below is used to represent the terminal symbol. AND TECHNO LOGY o Input/output Symbol: The input symbol is used to represent the input data, and the output symbol is used to display the output operation. The symbol given below is used for representing the Input/output symbol. o Processing Symbol:It is represented in a flowchart with the help of a rectangle box used to represent the arithmetic and data movement instructions. The symbol given below is used to represent the processing symbol. Page6 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE o Decision Symbol: Diamond symbol is used for represents decision-making statements. The RING symbol given below is used to represent the decision symbol. AND TECHNO LOGY o Connector Symbol:The connector symbol is used if flows discontinued at some point and continued again at another place. The following symbol is the representation of the connector symbol. o Flow lines: It represents the exact sequence in which instructions are executed. Arrows are used to represent the flow lines in a flowchart. The symbol given below is used for Page7 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE representing the flow lines: RING AND TECHNO LOGY Advantages of Flowchart in C: o Communication: A flowchart is a better way of communicating the logic of a program. o Synthesis: Flowchart is used as working models in designing new programs and software systems. o Efficient Coding: Flowcharts act as a guide for a programmer in writing the actual code in a high-level language. o Proper Debugging: Flowcharts help in the debugging process. o Effective Analysis: Effective analysis of logical programs can be easily done with the help of a related flowchart. o Proper Documentation: Flowchart provides better and proper documentation. It consists of various activities such as collecting, organizing, storing, and maintaining all related program records. o Testing: A flowchart helps in the testing process. o Efficient program maintenance: The maintenance of the program becomes easy with the help of a flowchart. Disadvantages of Flowchart in C: Following are the various disadvantages of flowchart: o Time-consuming: Designing a flowchart is a very time-consuming process. Page8 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE o Complex: It isn't easy to draw a flowchart for large and complex programs. RING o There is no standard in the flowchart; there is no standard to determine the quantity of AND detail. TECHNO LOGY o Difficult to modify: It is very difficult to modify the existing flowchart. Examples of flowchart: Example 1: Design a flowchart for adding two numbers entered by the user. Example 2: Design a flowchart for finding the largest among three numbers entered by the user. Page9 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 3: Design a flowchart for calculating the profit and loss according to the value entered by the user. Page10 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 4: Draw a flowchart to calculate the average of two numbers. Page11 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 5: Design a flowchart for the multiplication of three numbers entered by the user. Page12 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 6: Design a flowchart for calculating the area of a rectangle. Page13 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 7: Design a flowchart for calculating the Simple Interest according to the value entered by the user. Page14 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Example 8: Design a flowchart for checking whether the number is positive or negative according to the number entered by the user. Page15 Faculty: SHAHRUKH KAMAL [email protected] ALIGARH COLLEGE OF ENGINEERING AND TECHNOLOGY Subject:- Computer Fundamentals and MS-Office(PAPER CODE: C-101) ALIGARH COLLEGE Unit-2 Computer Fundamentals and MS-Office OF ENGINEE RING AND TECHNO LOGY Page16 Faculty: SHAHRUKH KAMAL [email protected]

Use Quizgecko on...
Browser
Browser