NEB Class 12 · Past paper
The complete NEB Class 12 2082 exam paper for Computer Science, all 10 questions with solved model answers.
Tap a question to open its answer.
Write any three differences between DDL and DML. Give examples of each.
DDL (Data Definition Language) and DML (Data Manipulation Language) are both subsets of SQL, but they serve different purposes.
| Basis | DDL | DML |
|---|---|---|
| Purpose | Defines and changes the structure of database objects | Manipulates the actual data stored inside the tables |
| Commands | CREATE, ALTER, DROP, TRUNCATE | SELECT, INSERT, UPDATE, DELETE |
| Effect on data | Does not directly work with row level data, only the schema | Directly adds, changes, retrieves or removes rows of data |
| Transaction control | Changes are usually auto-committed and cannot be rolled back in many systems | Changes can typically be rolled back before being committed |
Example of DDL:
CREATE TABLE student (regno INTEGER, name CHARACTER(25));
Example of DML:
INSERT INTO student VALUES (101, 'Ram');
What is normalization ? Explain 2NF and 3NF.
Normalization is the process of organizing the tables and columns of a relational database so as to minimize data redundancy and avoid update, insertion and deletion anomalies, usually by progressively breaking large tables into smaller, well structured related tables.
Second Normal Form (2NF): a table is in 2NF when it is already in 1NF (all attributes atomic, no repeating groups) and every non key attribute depends on the whole primary key, not on just part of it. This matters mainly for tables with a composite key; if a non key column depends on only part of the composite key, that partial dependency is removed by splitting the table.
Third Normal Form (3NF): a table is in 3NF when it is already in 2NF and, in addition, no non key attribute depends on another non key attribute (that is, there is no transitive dependency). For example, if a table stores StudentID, DepartmentID, DepartmentName, then DepartmentName depends on DepartmentID, which itself is not the primary key, so this is a transitive dependency; achieving 3NF means moving DepartmentName into its own Department table.
In short, 2NF removes partial dependency on a composite key, while 3NF goes further and removes dependency of one non key column on another non key column.
csc-dbms-relational
Write JavaScript code to input any three numbers and find the smallest number among them.
function findSmallest(a, b, c) {
let smallest = a;
if (b < smallest) {
smallest = b;
}
if (c < smallest) {
smallest = c;
}
return smallest;
}
let x = 12, y = 7, z = 9;
console.log("The smallest number is " + findSmallest(x, y, z));
The function starts by assuming a is the smallest, then checks b against the current smallest and updates it if b is smaller, and finally does the same check with c. After both comparisons, smallest holds the least of the three values. For x = 12, y = 7, z = 9 the code prints "The smallest number is 7".
Write a PHP script to connect to a MySQL database.
<?php
$server = "localhost";
$username = "root";
$password = "";
$database = "test";
$conn = mysqli_connect($server, $username, $password, $database);
if ($conn) {
echo "Connected successfully to the database";
} else {
echo "Connection failed: " . mysqli_connect_error();
}
?>
mysqli_connect() is called with the server name, username, password and the name of the database to connect to; it returns a connection object if the login and database selection succeed. The if statement then checks whether $conn was returned successfully and prints a confirmation message, or otherwise prints the connection error using mysqli_connect_error().
Write short notes on class and inheritance in oops with example.
Class: in object oriented programming, a class is a user defined blueprint that specifies the data members (properties) and member functions (methods) that its objects will have. It does not itself hold real data; it only describes the structure and behavior that each object created from it will share.
Inheritance: inheritance is the OOP feature that lets a new class (called the derived or child class) acquire the properties and methods of an existing class (called the base or parent class), and then add its own extra features or override existing ones. This avoids rewriting code that already exists in the base class.
Example: a base class Vehicle might define common properties such as speed and a method move(). A derived class Car can inherit from Vehicle, automatically getting speed and move(), while adding its own property such as numberOfDoors. Similarly, Bike can also inherit from Vehicle with its own extra features. This way, common behavior is written once in Vehicle and reused in every derived class, which is the essence of inheritance.
csc-oop-inheritance
What is Requirement Gathering ? Explain different Requirement Gathering methods.
Requirement gathering is the activity, carried out during the analysis phase of the SDLC, of collecting information from users, stakeholders and existing documents about what the new or improved system should do.
Different requirement gathering methods:
Using several of these methods together gives the analyst a more complete and accurate picture of the true requirements than relying on just one method.
What is AI ? Explain application areas of AI in education.
Artificial Intelligence (AI) is the branch of computer science concerned with building systems that can perform tasks which normally require human intelligence, such as learning, reasoning, understanding language and recognizing patterns.
Application areas of AI in education:
What is transmission medium ? Explain its major types with advantages and disadvantages.
A transmission medium is the physical or wireless path through which data signals travel from a sender to a receiver in a communication system, such as a cable or the air itself.
Transmission media are broadly divided into guided (wired) and unguided (wireless) types.
Guided media (signal travels along a physical conductor):
Unguided media (signal travels through free space):
In general, guided media give more reliable and secure transmission over shorter, fixed distances, while unguided media trade some reliability for mobility and ease of coverage over larger or difficult to cable areas.
Write a C program that reads the account_number, name and address of ten customers from users and displays the account_number, name and address of these customers using Array and structure.
#include <stdio.h>
struct Customer {
int account_number;
char name[30];
char address[50];
};
int main() {
struct Customer c[10];
int i;
for (i = 0; i < 10; i++) {
printf("Enter account number, name and address of customer %d: ", i + 1);
scanf("%d %s %s", &c[i].account_number, c[i].name, c[i].address);
}
printf("\nAccount Number\tName\tAddress\n");
for (i = 0; i < 10; i++)
printf("%d\t%s\t%s\n", c[i].account_number, c[i].name, c[i].address);
return 0;
}
The structure Customer groups the account_number, name and address of one customer, and the array c[10] stores the records of all ten customers. The first for loop reads these three fields for each customer from the user, and the second for loop then prints the account number, name and address of every customer stored in the array.
What are the components of a function of C ? Describe the Call - by - value and Call - by - reference and passing the function parameters.
Components of a function in C:
int add(int, int);.{ }) that carry out the task.add(3, 4);.return sum;.Call by value: in this method, a copy of the actual argument's value is passed to the function's parameter. Because the function works only on this copy, any change made to the parameter inside the function does not affect the original variable in the calling function.
void increment(int x) {
x = x + 1;
}
Calling increment(a) does not change a in the caller, since x is only a local copy.
Call by reference: in this method, the address of the actual argument is passed (using a pointer), so the function receives a pointer to the original variable. Any change made through this pointer inside the function directly modifies the original variable in the calling function.
void increment(int *x) {
*x = *x + 1;
}
Calling increment(&a) does change a in the caller, because x holds the address of a and *x dereferences it to modify the original value directly.
<?php
$server = "localhost";
$username = "root";
$password = "";
$database = "test";
$conn = mysqli_connect($server, $username, $password, $database);
if ($conn) {
echo "Connected successfully to the database";
} else {
echo "Connection failed: " . mysqli_connect_error();
}
?>
mysqli_connect() is called with the server name, username, password and the name of the database to connect to; it returns a connection object if the login and database selection succeed. The if statement then checks whether $conn was returned successfully and prints a confirmation message, or otherwise prints the connection error using mysqli_connect_error().