HND - SWE - Case Study - 2025 - More Revision Questions 2
HND - SWE - Case Study - 2025 - More Revision Questions 2
#include <iostream>
#include <string>
using namespace std;
int main() {
string str, reversedStr;
cout << "Enter a string: ";
getline(cin, str);
3. (15 Marks) What is a data structure? Compare arrays and linked lists in terms of memory, performance, and use cases.
o Answer:
▪ Data Structure: A way of organizing data for efficient access and modification.
▪ Arrays:
▪ Fixed size, contiguous memory allocation.
▪ Fast random access, but inserting/deleting elements is costly.
▪ Used for static data and indexed access.
▪ Linked Lists:
▪ Dynamic size, memory allocated for each node.
▪ Slow access due to sequential traversal, but efficient insertion/deletion.
▪ Used for dynamic data with frequent insertions/deletions.
4. (10 Marks) Write an algorithm to sort an array using the Bubble Sort method.
o Answer:
1. Start.
2. Input array and its size.
3. Repeat for (size - 1) iterations:
a. For each pair of adjacent elements:
i. If the current element > next element, swap them.
4. End.
INSERT INTO Courses (CourseID, CourseName, Credits) VALUES (1, 'Database Systems', 4);
INSERT INTO Courses (CourseID, CourseName, Credits) VALUES (2, 'Web Development', 3);
2. (10 Marks) Explain the MERISE methodology and its role in database development.
o Answer:
▪ MERISE Methodology: A structured approach for analyzing, designing, and implementing information systems.
▪ Key Phases:
▪ Conceptual Model: High-level representation of data and processes.
▪ Logical Model: Maps entities to tables and defines relationships.
▪ Physical Model: Implements the logical design in a database system.
▪ Significance: Ensures a well-organized and scalable database design.
1. (8 Marks) Write HTML and CSS code to display a contact form with fields for Name, Email, and Message. Include a "Submit" button.
o Answer:
<!DOCTYPE html>
<html>
<head>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" required></textarea>
<button type="submit">Submit</button>
</form>
</body>
</html>
2. (7 Marks) Explain the difference between inline, internal, and external CSS with examples.
o Answer:
▪ Inline CSS: Applied directly to an element using the style attribute.
<style>
p { color: red; }
</style>
1. (10 Marks) Design a flowchart to calculate the factorial of a given number nnn.
o Answer:
Steps for Flowchart:
1. Start.
2. Input nnn.
3. Initialize fact=1fact = 1fact=1.
4. For i=1i = 1i=1 to nnn: fact=fact×ifact = fact \times ifact=fact×i.
5. Print factfactfact.
6. End.
(Flowchart uses looping for the iterative calculation of the factorial.)
2. (15 Marks) Write a C program to find the second largest number in an array of 10 integers.
o Answer:
#include <stdio.h>
int main() {
int arr[10], largest, second_largest, i;
#include <iostream>
using namespace std;
class Animal {
public:
void eat() {
cout << "This animal eats food." << endl;
}
};
int main() {
Dog myDog;
myDog.eat(); // Inherited from Animal
myDog.bark(); // Defined in Dog
return 0;
}
4. (10 Marks) Compare and contrast C programming and C++ programming in terms of features and applications.
o Answer:
▪ C Programming: Procedural, lacks object-oriented features, used for system-level programming (e.g., operating
systems).
▪ C++ Programming: Supports OOP (e.g., classes, inheritance), used for developing applications like games, GUIs, and
real-time systems.
2. (10 Marks) What is Normalization? Explain its significance and define the 1NF, 2NF, and 3NF with examples.
o Answer:
▪ Normalization: Process of organizing data in a database to reduce redundancy and improve data integrity.
▪ 1NF: Atomic values, no repeating groups.
▪ Example: Split columns with multiple values into separate rows.
▪ 2NF: 1NF + no partial dependencies (every non-key column depends on the whole primary key).
▪ Example: Remove attributes that depend on part of a composite key.
▪ 3NF: 2NF + no transitive dependencies.
▪ Example: Remove columns that depend on non-key attributes.
1. (8 Marks) Write HTML and CSS to create a simple webpage that displays a centered heading and a navigation bar with three links
(Home, About, Contact).
o Answer:
<!DOCTYPE html>
<html>
<head>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
2. (7 Marks) Explain the difference between GET and POST methods in web development. Provide a PHP script to process a simple
form using POST.
o Answer:
▪ GET: Sends data via the URL, limited in size, less secure.
▪ POST: Sends data in the HTTP body, larger data capacity, more secure.
▪ PHP Script:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
echo "Welcome, " . htmlspecialchars($name);
}
?>
(Flowchart uses decision blocks for comparisons and I/O blocks for inputs/outputs.)
2. (15 Marks) Write a C program to reverse a given string without using built-in string functions.
o Answer:
3. (10 Marks) Differentiate between procedural programming and event-driven programming with examples.
o Answer:
▪ Procedural Programming: Follows a step-by-step procedure to execute tasks. Example: C (main function with
subroutines).
▪ Event-Driven Programming: Executes code in response to events like user actions. Example: VB.NET (code triggered
by a button click).
4. (15 Marks) Write a Java program that uses inheritance to create a base class Shape and a derived class Rectangle. The Rectangle
class should calculate and display its area.
o Answer:
class Shape {
int length, width;
2. (10 Marks) Define Primary Key and Foreign Key in databases and explain their purpose with examples.
o Answer:
▪ Primary Key: A unique identifier for each record in a table. Example: EmpID in Employees.
▪ Foreign Key: A field in one table that refers to the Primary Key in another table, establishing a relationship between
tables. Example: DeptID in Employees referencing DeptID in Departments.
1. (8 Marks) Write a basic HTML structure with CSS to create a red-colored button labeled "Click Me!".
o Answer:
<!DOCTYPE html>
<html>
<head>
<style>
.button {
background-color: red;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<button class="button">Click Me!</button>
</body>
</html>
2. (7 Marks) Write a PHP script to fetch all records from a MySQL table called Products and display them in a table.
o Answer:
<?php
$conn = mysqli_connect("localhost", "root", "", "test_db");
$result = mysqli_query($conn, "SELECT * FROM Products");
mysqli_close($conn);
?>
#include <stdio.h>
int main() {
int n, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d natural numbers = %d\n", n, sum);
return 0;
}
3. (10 Marks) Explain the difference between structured programming and object-oriented programming (OOP).
o Answer:
▪ Structured Programming: Focuses on using procedures and functions to execute tasks. Example: C.
▪ Object-Oriented Programming: Organizes code into objects, which combine data and methods. Example: C++ or Java.
4. (15 Marks) Write a C++ program to create a class Rectangle with methods to calculate its area and perimeter.
o Answer:
#include <iostream>
using namespace std;
class Rectangle {
public:
int length, width;
int area() {
return length * width;
}
int perimeter() {
return 2 * (length + width);
}
};
int main() {
Rectangle r;
INSERT INTO Students (ID, Name, Age) VALUES (1, 'Jane Smith', 22);
2. (10 Marks) Define MERISE and explain its main purpose in database design.
o Answer:
▪ Definition: MERISE is a methodology used to design and manage databases by separating technical, logical, and
conceptual processes.
▪ Purpose: It helps in the structured design of databases and systems by using a step-by-step approach.
1. (8 Marks) Write a basic HTML structure to display a table of 3 rows and 2 columns.
o Answer:
<!DOCTYPE html>
<html>
<head>
<title>Sample Table</title>
</head>
2. (7 Marks) Write a PHP script to connect to a MySQL database and display "Connection successful" if the connection is established.
o Answer:
<?php
$conn = mysqli_connect("localhost", "root", "", "test_db");
if ($conn) {
echo "Connection successful";
} else {
echo "Connection failed: " . mysqli_connect_error();
}
?>
1. (10 Marks) Explain the purpose of IP addressing in a network. How does subnetting improve a network?
o Answer:
▪ IP Addressing Purpose: To uniquely identify devices on a network and enable data exchange.
▪ Subnetting: Divides a large network into smaller segments to improve efficiency, reduce congestion, and enhance
security.
2. (5 Marks) What is the difference between LAN and WAN?
1. (10 Marks) Write an algorithm to find the largest number among three user-provided numbers.
o Answer:
Algorithm:
1. Start
2. Input three numbers: aaa, bbb, ccc
3. Compare aaa, bbb, and ccc:
▪ If a>ba > ba>b and a>ca > ca>c, then aaa is the largest
▪ Else if b>ab > ab>a and b>cb > cb>c, then bbb is the largest
▪ Else ccc is the largest
4. Display the largest number
5. End
2. (15 Marks) Write a C program to calculate the factorial of a number entered by the user.
o Answer:
#include <stdio.h>
int main() {
int n, i, factorial = 1;
printf("Enter a positive integer: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
factorial *= i;
}
printf("Factorial of %d = %d\n", n, factorial);
return 0;
3. (10 Marks) Define the term data structure and give two examples of data structures commonly used in programming.
o Answer:
▪ Definition: A data structure is a way of organizing and storing data in a computer so that it can be used efficiently.
▪ Examples:
▪ Array: A collection of elements, each identified by an index.
▪ Linked List: A sequence of nodes where each node contains data and a pointer to the next node.
4. (15 Marks) Write a C++ program to create a class Student with attributes name and age. Add a method to display the student's details.
o Answer:
#include <iostream>
using namespace std;
class Student {
public:
string name;
int age;
void displayDetails() {
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
}
};
int main() {
Student s;
s.name = "Alice";
s.age = 20;
s.displayDetails();
return 0;
}
2. (10 Marks) Explain the difference between a primary key and a unique key in a database.
o Answer:
▪ Primary Key: Ensures each row in a table has a unique identifier; a table can only have one primary key.
▪ Unique Key: Ensures all values in a column are unique; a table can have multiple unique keys.
1. (8 Marks) Create a basic HTML form with fields for Name, Email, and a Submit button.
o Answer:
<!DOCTYPE html>
<html>
<head>
<title>Simple Form</title>
</head>
<body>
<form action="submit.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
2. (7 Marks) Write a PHP script to fetch all records from a users table in a MySQL database and display them in an HTML table.
<?php
if (!$conn) {
echo "</table>";
mysqli_close($conn);
?>