1.
Computer Hardware and Software
• Hardware: The physical parts of the computer:
o Input Devices: Keyboard, mouse, etc., for entering data.
o CPU: Processes data and instructions.
o Primary Storage: Temporary memory (RAM).
o Output Devices: Monitor, printer for displaying results.
o Auxiliary Storage: Permanent storage (hard drive, SSD).
• Software: Programs that tell the hardware what to do:
o System Software: Manages hardware (like operating systems).
o Application Software: Helps users perform tasks (e.g., word processors).
System Software: Manages hardware and system tasks.
1. Operating System: Controls resources and user interface.
2. System Support: Includes utilities like disk formatting and security.
3. System Development: Tools like compilers for coding.
Application Software: Helps users perform specific tasks.
1. General-Purpose: Used for various tasks (e.g., word processors).
2. Application-Specific: For one specific task (e.g., accounting software).
2. Creating and Running Programs
1. Write: Create the program in a text editor.
2. Compile: Translate the code into machine language.
3. Link: Add external functions.
4. Execute: Run the program on the computer.
3. Program Development Cycle
1. Understand the Problem: Analyze the requirements.
2. Design: Plan the solution (e.g., flowchart).
3. Write: Code the program.
4. Test: Check if it works correctly.
5. Maintain: Fix issues and update when needed.
4. Explain about Algorithm ? or Define Algorithm and State Properties of it ?
Ans :
An algorithm is a set of steps to complete a specific task. An algorithm should meet these criteria:
• Input: It must accept some input values.
• Output: At least one result is produced.
• Definiteness: Each step must be clear and precise.
• Finiteness: It must complete in a limited number of steps.
• Effectiveness: All steps must be simple and practical to perform.
5. Advantages of Algorithms:
• Gives a clear solution to a problem.
• Can be used with any programming language.
• Helps design and develop programs.
• Makes it easier to understand the solution.
• Helps find and fix mistakes.
• Allows finding the best solution.
Disadvantages of Algorithms:
• Hard to follow in big programs.
• No visuals, so it’s harder to understand than flowcharts.
6. Example 1: Add Two Numbers
1. Start
2. Read two numbers as A and B
3. Add A and B, store the result in C
4. Display C
5. Stop
Example 2: Average of Three Numbers
1. Start
2. Read three numbers as a, b, and c
3. Add the three numbers and divide the total by 3
4. Store the result in d
5. Display d
6. Stop
Example 3: Average of n inputted numbers.
1. Start
2. Read the number of inputs, n
3. Set i = 0 and sum = 0
4. While i < n:
o Read a number, a
o Add a to sum
o Increase i by 1
5. Divide sum by n and store the result in avg
6. Print avg
7. Stop
Example 4: Find the Largest of Two Numbers
1. Start
2. Read two numbers, A and B
3. If A > B, print A is the largest
4. Otherwise, print B is the largest
5. Stop
Example 5: Find the Factorial of a Number
1. Start
2. Read a number, n
3. Set factorial = 1
4. While n > 0:
o Multiply factorial by n
o Decrease n by 1
5. Print factorial
6. Stop
Example 6: Check if a Number is Even or Odd
1. Start
2. Read a number, n
3. If n % 2 == 0, print Even
4. Otherwise, print Odd
5. Stop
Example 7: Sum of First N Natural Numbers
1. Start
2. Read a number, n
3. Set sum = 0
4. For each number from 1 to n, do:
o Add the number to sum
5. Print sum
6. Stop
Example 8: Reverse a Number
1. Start
2. Read a number, n
3. Set reverse = 0
4. While n > 0:
o Get the last digit of n using n % 10
o Multiply reverse by 10 and add the digit
o Remove the last digit from n using n // 10
5. Print reverse
6. Stop
7 . Flowchart
A flowchart is a visual way to show the steps of solving a problem using symbols. It is a picture of an
algorithm, making it easier to understand. The first flowchart was created by John Von Neumann in
1945.
Purpose of a Flowchart:
• Simplifies communication.
• Gives an overview of processes.
• Shows steps and their relationships.
• Quickly displays program flow and logic.
Advantages:
• Helps in algorithm design.
• Easier to understand than a program.
• Works with any programming language.
• Clear and organized presentation.
Limitations:
• Hard to use for complex logic.
• Time-consuming to draw.
• Difficult to revise and remember.
8.Explain the Symbols in a Flowchart ? Ans: Symbols : Symbols are divided in to the following
two parts.
l. Auxiliary Symbols.
ll. Primary Symbols.
9. Write an algorithm and flow chart for swapping two numbers
To Swap Two Integer Numbers:
Algorithm (a): Using a Third Variable
1. Start
2. Input num1, num2
3. Set temp = num1
4. Set num1 = num2
5. Set num2 = temp
6. Output num1, num2
7. Stop
Algorithm (b): Without Using a Third Variable
1. Start
2. Input num1, num2
3. Set num1 = num1 + num2
4. Set num2 = num1 - num2
5. Set num1 = num1 - num2
6. Output num1, num2
7. Stop