0% found this document useful (0 votes)
41 views10 pages

Continuous Assessment Test II - Computing Essentials

Uploaded by

kowsalya0910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views10 pages

Continuous Assessment Test II - Computing Essentials

Uploaded by

kowsalya0910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SHANMUGANAHANENGINEERINGCOLLEGE

(AccreditedbyNAAC&ISO9001:2015CertifiedInstitution)
ARASAMPATTI–622507

CONTINUOUS ASSESSMENT TEST-II(SET-II)


BRANCH :B.E(CSE,AIML,CYBE SUBCODE :CS25C03
R,IT &AIDS)
YEAR/SEM :I/I SUBTITLE :ESSENTIAL OF COMPUTING
DATE :06-11-25 [Link] :[Link] &[Link].,AP/CSE
TIME: 9.30am-11.10am MAXMARKS : 60

Answer key
Answer All Questions.
PART–A (9X2=18)
1. What are the components of a Loop?
A loop consists of the following components:
1. Initialization – Starting value of the loop variable

2. Condition / Test Expression – Checks whether the loop should continue

3. Update / Increment–Decrement – Changes loop variable after each iteration

4. Body of the Loop – Statements to be executed repeatedly

2. Characteristics of a Good Algorithm


1. Input – Clearly defined input values

2. Output – Clearly defined results


3. Definiteness – Steps must be clear and unambiguous
4. Finiteness – Must terminate after a finite number of steps
5. Effectiveness – Steps must be simple and feasible
6. Efficiency – Uses minimum time and memory
7. Generality – Should solve a class of problems, not just one case

3. List three ways to represent algorithms.


1. Pseudocode

2. Flowchart

3. DecisionTables
(Additionally: Structured English, program code, diagrams)

4. What is Algorithm Discovery?


Algorithm Discovery is the process of finding or developing a step-by-step solution to solve a
Problemefficiently.
It involves analyzing the problem, identifying patterns, and designing an effective method.

5. What is Big O Notation?


Big O Notation is a mathematical notation used to describe the time or space complexity of
analgorithm.
It measures how fast the algorithm grows as the input size increases.
Example:
 O(1) → Constant time
 O(n) → Linear time
 O(n²) → Quadratic time

6. Why is C called a Middle-Level Language?


C is called a middle-level language because it has features of:
 Low-level language (close to hardware, pointers, memory access)
 High-level language (functions, loops, portability, readability)
Thus, it provides both machine-level control and high-level abstraction.

7. Differentiate between Algorithm and Flowchart


Algorithm Flowchart
Step-by-step written instructions Diagrammatic representation
Written in simple English or pseudocode Uses symbols like arrows, rectangles, diamonds
Easy to modify Harder to change once drawn
No standard format Standard symbols are used

8. Write an algorithm to find the largest of two numbers.


Algorithm: Largest of Two Numbers
1. Start

2. Read A and B

3. IfA>B,then
Display A is largest

4. Else
Display B is largest
5. End

9. Write a Pseudocode to add two matrices.


Pseudocode: Matrix Addition
Begin
Read m, n // number of rows and columns
For i ← 1to m
For j ← 1to n
Read A[i][j]
For i ← 1to m
For j ← 1to n
Read B[i][j]
For i ← 1to m
For j ← 1to n
C[i][j] ← A[i][j] + B[i][j]
Display matrix C
End
PART–B(3X14=42)
10.(a)Explain the role of logical reasoning in software development with the help of suitable examples. (14)
Role of Logical Reasoning in Software
Development
Logical reasoning is the ability to think systematically, analyze problems, and make decisions based on rules
and structured thinking.
In software development, logical reasoning is essential because programming requires breaking down problems,
identifying patterns, and creating instructions the computer can follow.

Logical reasoning helps developers to:

 Understand the problem correctly


 Break the problem into smaller parts
 Create effective algorithms
 Predict program behavior
 Debug and fix errors
 Make correct decisions using conditions and loops
1. Problem Solving and Algorithm Design
Before writing code, a developer must design an algorithm using logical steps.
Example:
Problem: Find the largest of three numbers.
Logical reasoning helps determine:
 Compare A and B

 Then compare the larger value with C


 Decide the largest number using conditions

Algorithm (logic):
If A>B and A> C → A is largest
Else if B> C → B is largest
Else → C is largest
This logic forms the basis of the program.
2. Using Conditions (Decision Making)
Programming requires decisions using logical operators like AND, OR, NOT.
Example:
A login system:
If (username is correct) AND (passwordis correct)
Allow login
Else
Display "Invalid login"
Without correct logical reasoning, the system may allow wrong users or block valid users.
3. Loops and Repetition
Logical reasoning helps in deciding:
 How many times the loop should run

 When to stop
 What condition controls the loop


Example:
Printing numbers 1 to 10:

i = 1
while (i <= 10)
print i
i = i + 1
The loop depends on a logical condition (i ≤ 10).
4. Debugging and Error Detection
Logical reasoning is used to find why a program is not giving correct output.
Example:
If a total value is always zero, the developer reasons:
 Is the variable initialized?
 Is the loop adding values?

 Is the condition wrong?


Through logical analysis, the error is found and fixed.
5. Designing Data Structures
Logical reasoning is used to select the right data structure:
 Array → when storing fixed-size data
 Stack → for undo operations

 Queue → for scheduling


Example:
In a printer queue, documents must print in order.
Using a queue (FIFO logic) ensures correct sequence.
6. Writing Efficient Code
Logical reasoning helps eliminate unnecessary steps and improve performance.
Example:
Instead of checking all 100 elements to find an even number,
 Check each element
 Stop as soon as the first even number is found
This logic improves efficiency.
7. Real-Life Example in Software
Example: ATM Withdrawal Logic
If balance >= withdrawal amount AND amount % 100 == 0
Approve transaction
Else
Display error
Logical reasoning ensures:
 The user has enough balance
 The amount is valid
 The system works safely
(OR)
(b)(i) Define recursive? Write a recursive algorithm for computing the factorial of a numbers.(7)
Definition of Recursive
Recursion is a technique in which a function or algorithm calls itself to solve a smaller sub-problem of the
original problem.
A recursive solution must contain:
1. Base Case – the stopping condition
2. Recursive Case – the function calling itself with a smaller input
Recursive Algorithm for Factorial
The factorial of a number n (written as n! ) is:
 0! = 1 (Base case)
 n! = n × (n – 1)! for n > 0 (Recursive case)
Algorithm: Recursive Factorial
1. Start
2. Read n
3. If n = 0
Return 1
4. Else
Return n × factorial(n – 1)
5. End
Explanation
 When n = 0, the algorithm stops and returns 1.

 Otherwise, it calls itself with n – 1 until the base case is reached.

(ii)Write a Algorithm for Exchanging values of Two variables and Summation of a set of Numbers (7)
Algorithm for Exchanging Values of Two
Variables
Aim: To exchange (swap) the values of two variables A and B.
Algorithm
1. Start

2. Read A and B
3. Set TEMP ← A
4. Set A ← B
5. Set B ← TEMP
6. Display A and B
7. End

2. Algorithm for Summation of a Set of Numbers


Aim: To find the sum of N numbers.
Algorithm
1. Start

2. Read N (number of values)


3. Set SUM ← 0
4. Set i ← 1
5. Repeat steps 6–7 while i ≤ N
6. Read NUMBER
7. SUM ← SUM + NUMBER
8. Increment i ← i + 1
9. Display SUM
10. End

11.(a)(i)Construct a flowchart and write an algorithm to find whether a given number is prime (or)not. (7)
Algorithm: Check Whether a Number Is
Prime
Step 1: Start
Step 2: Read the number N
Step 3: If N ≤ 1, then print "Not Prime" and stop
Step 4: Set i = 2
Step 5: Repeat while i ≤ N/2
a. If N % i == 0, then print "Not Prime" and stop
b. Increment i = i + 1
Step 6: If no divisor is found, print "Prime Number"
Step 7: Stop

(ii)Write an algorithm and draw flowchart to find factorial of a given number. (7)
Algorithm to Find Factorial of a Number
Step 1: Start
Step 2: Read the number N
Step 3: Set fact = 1
Step 4: Set i = 1
Step 5: Repeat while i ≤ N
a. fact = fact × i
b. i = i + 1
Step 6: Print fact
Step 7: Stop

(OR)
(b)Explain the various phases in the program development life cycle. (14)
Phases in the Program Development Life
Cycle
The program development process follows a series of structured steps. These steps ensure the program is
correct, efficient, and meets user requirements.
1. Problem Definition
 Understand the exact problem to be solved.

 Identify what inputs are required and what outputs are expected.
 Clarify constraints and requirements.
Example:
User wants a program to find the area of a circle given radius.
2. Feasibility Study
 Check if the problem can be solved with available time, cost, tools, and skills.

 Decide whether to proceed or not.


3. Algorithm Design
 Develop a step-by-step procedure to solve the problem.
 Focus on logic, not programming language.
 Algorithm may be represented using pseudocode or flowchart.
4. Coding / Program Development
 Translate the algorithm into a programming language (C, Python, Java, etc.)
 Choose suitable data types and syntax.
5. Testing and Debugging
 Run the program with various test cases.

 Find and correct errors such as:


o Syntax errors
o Logic errors
o Runtime errors
6. Documentation
 Prepare user manuals, program description, comments, and technical reports.

 Helps future maintenance and understanding.


12.(a)(i)Describe the various program design tools? (7)
Program design tools help programmers plan, visualize, and document the logic of a program before writing
actual code. They make algorithms easy to understand, modify, and debug.
Below are the most commonly used program design tools:
1. Algorithms
 An algorithm is a step-by-step procedure to solve a problem.
 Written in simple English statements.
 Focuses on what to do without worrying about syntax.
Example:
Algorithm to add two numbers.
2. Flowcharts
 A graphical representation of an algorithm.
 Uses symbols like:
o Oval → Start/Stop
o Parallelogram → Input/Output
o Rectangle → Process
o Diamond → Decision
 Helps visualize the program’s logical flow.
Benefits: easy to read, debug, and communicate.
3. Pseudocode
 A high-level description of an algorithm using plain English + programming-like statements.
 Does not follow strict syntax rules.
 Makes transition to coding easier.
Example:
Input A, B
Sum = A + B
Print Sum
4. Decision Tables
 A table that represents different conditions and actions.
 Useful when there are many complex conditions.
Components:
 Condition stubs
 Action stubs
 Rules
Example: Calculating discounts based on purchase amount.
5. Decision Trees
 A tree-like diagram showing decisions and their possible outcomes.
 Starts from a root decision and branches into many paths.
 Useful in conditional or rule-based problems.
6. Structure Charts
 Also called Hierarchy Charts.
 Shows the breakdown of a program into modules.
 Represents the overall design in a top-down approach.
Example:
A payroll system divided into:
 Input Module
 Processing Module
 Output Module

7. Data Flow Diagrams (DFD)


 Represents the flow of data in a system.
 Shows where data comes from, how it is processed, and where it goes.
Elements:
 External entities
 Processes
 Data stores
 Data flow arrows
Used mainly in system analysis.

(ii)Give the comparison between High-level Language and Low-Level Language. (7)
High-Level Language (HLL) Low-Level Language (LLL)
Closer to human language and easy to Closer to machine language and harder to
understand. understand.
Easy to write, debug, and maintain. Difficult to write and debug.
Portable – can run on different machines with Not portable – depends on machine
little or no change. architecture.
Requires compiler/interpreter for Requires assembler for translation (machine
translation. code/assembly).
Slow execution because translation overhead Fast execution because instructions are low-
is high. level.
Examples: C, Java, Python, BASIC Examples: Machine language, Assembly
language
Programmer focuses on logic, not hardware Programmer must know hardware
details. architecture (registers, memory).

(OR)
(b)(i)Explain Imperative Programming Paradigm with an diagram .(7)
The Imperative Programming Paradigm is a style of programming where the programmer gives step-by-step
instructions to the computer on how to perform a task.
It focuses on how the program operates, not just on what the result should be.
✔ Key Characteristics
 Uses statements that change the program’s state.

 Based on sequences, loops, and conditionals.


 Uses variables, assignments, and control flow statements.
 Follows the von Neumann architecture (memory + CPU).
✔ Examples of Imperative Languages
C, C++, Java, Python, Pascal, FORTRAN
✔ How It Works
Imperative programming tells the computer HOW to do something using:
 Assignment statements

 If-else decisions

 Loops (for, while)


 Procedures/functions

Diagram of Imperative Programming Paradigm


┌─────────────────────────┐
│ Imperative Programming │
└─────────────┬───────────┘


┌─────────────────────────▼─────────────────────────┐
│ Sequence of Statements (Step-by-step) │
└─────────────────────────┬─────────────────────────┘

┌─────────────────────▼────────────────────┐
│ Control Structures Used: │
├──────────────────────────────────────────┤
│ • Selection (if, switch) │
│ • Iteration (for, while, do-while) │
│ • Assignment Statements │
└─────────────────────┬────────────────────┘

┌──────────▼──────────┐
│ State Changes │
│ (Variables update) │
└──────────┬──────────┘

┌─────────▼─────────┐
│ Final Output/Result│
└────────────────────┘

(ii)Difference between imperative and Declarative Programming Paradigms (7)


Feature Imperative Programming Declarative Programming
Focuses on how to perform tasks step by Focuses on what the program should achieve,
Definition
step. not how.
Explicit; programmer specifies the Implicit; language/runtime decides execution
Control Flow
sequence of operations. flow.
Frequently modifies program state and Avoids mutable state; emphasizes
State Changes
variables. immutability.
Programming Procedural, structured, object-oriented. Functional, logic-based, declarative queries
Feature Imperative Programming Declarative Programming
Style (SQL, HTML).
Low to medium; programmer handles High; focuses on logic, relationships, or
Abstraction Level
details. constraints.
Example
C, Java, Python (imperative style), C++ SQL, HTML, Prolog, Haskell, CSS
Languages
Debugging Easier to trace step by step. Can be challenging due to implicit execution.
Performance Programmer has direct control over Less control; performance depends on
Control performance and resources. runtime optimizations.
System programming, algorithms, Database queries, UI layout, configuration,
Use Cases
simulations. data transformation.

Staff in-charge HoD(I/C)-CSE

You might also like