Computer Science NEB grade 12 question model solution
Rewrite
the correct options for each question in your answer sheet. 9×1=9
1. Which of the
following SQL statement is used to DELETE rows from a database table?
A) DELETE
B) REMOVE
C) DROP
D)
CLEAR
2. A field that is
used to uniquely define a particular record in a table is called:
A) Primary Key
B) Entity
C) Relationship
D)
Constraints
3. What does
"MAC" stands for in MAC Address?
A) Mandatory Access Control
B) Media
Access Control
C) Micro Access Control
D)
Media Access Certificate
4. What is the
correct syntax for referring to an external JavaScript script?
A) <script src="myscript.js"></script>
B)
<script href="myscript.js"></script>
C) <js href="myscript.js"></js>
D)
<js src="myscript.js"></js>
5. Which of the
following is the correct way of defining a variable in PHP?
A) $variable name = value;
B) $variable_name
= value;
C) $variable_name = value
D)
$variable name as value;
6. What is the
output of C program?
void main(){ int
b=25;
//b memory
location=1234;
int *p; p=&b;
printf("%d %d", &b, p);}
A) 25 25
B) 1234 1234
C) 25 1234
D) 1234 25
7. Which feature of
OOP is illustrated the code reusability?
A) Polymorphism
B) Abstraction
C) Encapsulation
D)
Inheritance
8. Which of
following is the discovering requirement from a user in the requirement
collection process?
A) Feasibility study
B) Requirement Elicitation
C) Requirement Specification
D) Requirement validation
9. What devices are
detecting and responding to changes in an environment that are embedded in
smart phones and an integral part of the Internet of Things (IoT)?
A) Wi-Fi
B) Barcode
C) RFID
D)
Sensors
Group B
Short
answer questions. 5×5=25
10.
Differentiate the centralized and distributed database system.
Ans: A centralized database system is one in which all data is stored in
a single, central location and accessed by multiple users over a network. A
distributed database system, on the other hand, is one in which the data is
spread across multiple nodes or locations, and each node can be accessed and
modified independently.
There are several
key differences between centralized and distributed database systems:
Centralized
database system |
Distributed
database system |
Data
is stored in a single location |
Data
is spread across multiple nodes or locations |
If
the central server goes down, all users are unable to access the data |
Each
node can be accessed independently, so users can still access the data even
if some nodes are down |
May
become slow as the amount of data and number of users increase |
Can
scale more easily and handle larger amounts of data and users more
efficiently |
Central
server is a single point of failure and is vulnerable to attacks |
Data
is spread across multiple nodes, making it more difficult for attackers to
access or modify the data |
Easier
to maintain, as there is only one central server to manage |
Requires
more maintenance, as each node needs to be managed and kept up to date |
OR
What
are the purposes of normalization? Give an example of 2NF.
Ans: Normalization is the process of organizing a database in a way that
reduces redundancy and dependency. It is a systematic approach to design the
database structure so that data is stored in a way that is easy to maintain and
access. Normalization usually involves breaking a large table into smaller,
more specialized tables and defining relationships between them.
There are several
purposes of normalization:
v) To simplify database design and maintenance: Normalization helps to simplify database design and maintenance by breaking down large tables into smaller ones, which makes it easier to understand and modify the database structure.
2NF:
Here is an example of a table that is in 2NF:
In 2NF, the table is required in 1NF.
The main rule of 2NF is, 'No non-prime
attribute is dependent on the proper subset of any candidate key of the table.'
An attribute which is not part of candidate
key is known as non-prime attribute.
An attribute that is not part of any
candidate key is known as non-prime attribute.
Teacher_id |
Subject |
Teacher_age |
111 |
Maths |
38 |
111 |
Physics |
38 |
222 |
Biology |
38 |
333 |
Physics |
40 |
333 |
Chemistry |
40 |
Example: Suppose a school wants to store the data of teachers and the subjects they teach. They create a table that looks like as follows:
Since a teacher can
teach more than one subjects, the table can have multiple rows for a same
teacher.
Candidate Keys: {teacher_id,
subject}
Non prime attribute: teacher_age
The table is in 1 NF because each attribute has atomic values. However,
it is not in 2NF because non prime attribute teacher_age is dependent on
teacher_id alone which is a proper subset of candidate key. This violates the
rule for 2NF as the rule says “no non-prime attribute is dependent on the
proper subset of any candidate key of the table”.
To make the table
complies with 2NF we can break it in two tables like this:
teacher_details table:
Teacher_id |
Teacher_age |
111 |
38 |
222 |
38 |
333 |
40 |
teacher_subject table:
Teacher_id |
Subject |
111 |
Maths |
111 |
Physics |
222 |
Biology |
333 |
Physics |
333 |
chemistry |
Now the tables
comply with Second normal form (2NF).
11.
Write a program to find the factorial of any given number using JavaScript.
Ans:
<html>
<body>
</body>
<script>
let num =
prompt("Enter a number: "); //
prompt the user for a number
num =
parseInt(num);
var result =
1; // initialize the result to 1
for (var i = 1; i <= num; i++) { // loop from 1 to the input number
result =result*i; // multiply the result by the current value of i
}
document.write("factorial=",result);
</script>
</html>
OR
How do
you fetch data from database in PHP and display it in form? Describe.
Ans: To fetch data
from a database in PHP and display it in a form, you can use the MySQLi (MySQL
improved) extension or the PDO (PHP Data Objects) extension.
<?php
// Connect to the
database
$host =
'localhost';
$username =
'your_username';
$password =
'your_password';
$dbname =
'your_database';
$conn =
mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " .
mysqli_connect_error());
}
// Fetch data from
the database
$sql = "SELECT
* FROM users WHERE id = 1";
$result =
mysqli_query($conn, $sql);
// Check if data
was returned
if
(mysqli_num_rows($result) > 0) {
// Fetch the data and store it in a variable
$row = mysqli_fetch_assoc($result);
//
Display the data in a form
echo '<form>';
echo '<input type="text"
name="name" value="' . $row['name'] . '">';
echo '<input type="email"
name="email" value="' . $row['email'] . '">';
echo '</form>';
} else {
echo "No data found.";
}
// Close the
connection
mysqli_close($conn);
?>
In above example, the mysqli_connect function is used to connect to the
database. The mysqli_query function is then used to execute a SELECT query to
fetch data from the users table where the id is 1. The mysqli_num_rows function
is used to check if any data was returned.
12.
Compare the OOPs and procedural programming language.
Ans: Object-Oriented Programming (OOP) and Procedural Programming are
two programming paradigms, or approaches to organizing and structuring code.
Here are some key differences between OOP and Procedural Programming:
OOPs Programming
Language |
Procedural
Programming Language |
Data
is encapsulated within objects and classes |
Data
is stored in variables and arrays |
Objects
and classes have methods to manipulate data |
Functions
operate on variables and data structures |
Focuses
on the behavior and interaction of objects |
Focuses
on procedures and functions |
Encourages
code reuse through inheritance and polymorphism |
Code
reuse is limited to functions or libraries |
Provides
abstraction and modularity to manage complexity |
Code
is usually linear and can become unwieldy with increasing complexity |
Exception
handling can make it easier to manage errors |
Error
handling is usually done through return codes or global variables |
Object-oriented
languages usually have automatic memory management |
Memory
management is usually done manually |
Java,
C++, Python, Ruby |
C,
Pascal, Fortran, Basic |
13. What
are the major activities performed to design the software? Describe.
Ans: There are
several major activities that are typically performed when designing software.
These activities can vary depending on the specific project and the development
process being used, but some common activities include:
Requirements gathering and analysis: This involves gathering and documenting the requirements
for the software, including the functional and non-functional requirements.
This helps to define the scope of the project and ensure that the final product
meets the needs of the users.
System design: This
involves designing the overall architecture of the system, including the
components that will make up the system, their relationships, and how they will
work together. This helps to ensure that the system is scalable, maintainable,
and meets the requirements defined in the previous step.
Interface design:
This involves designing the user interface of the software, including the
layout, appearance, and functionality of the interface. This helps to ensure
that the software is easy to use and intuitive for the users.
Component design:
This involves designing the individual components that make up the system,
including the data structures, algorithms, and other details of their
implementation. This helps to ensure that the components are efficient and can
work together effectively to accomplish the overall goals of the system.
Prototyping: This
involves creating a prototype of the software, which can be used to test and
validate the design before building the final product. This helps to identify
any issues or problems with the design before the software is fully developed.
14.
Explain the popular five-application areas of AI.
Artificial intelligence (AI) has a wide range of potential applications,
and it is being used in many different fields and industries. Here are five
popular application areas of AI:
Natural Language Processing (NLP): This involves using AI to process and understand human
language, including speech and text. This is used in applications such as
language translation, speech recognition, and chatbots.
Computer Vision: This
involves using AI to extract information from images and videos, such as
recognizing objects, detecting patterns, and analyzing scenes. This is used in
applications such as image and video recognition, surveillance, and
self-driving cars.
Expert Systems:
This involves using AI to mimic the decision-making ability of a human expert
in a specific field. This is used in applications such as medical diagnosis,
financial analysis, and customer service.
Robotics: This
involves using AI to control and program robots to perform tasks. This is used
in applications such as manufacturing, assembly, and logistics.
Machine Learning:
This involves using AI to analyze data and learn from it, allowing the AI to
improve its performance over time. This is used in applications such as
predictive analytics, recommendation systems, and fraud detection.
Group 'C'
Long
answer questions 8×2=16
15. Compare the star and ring topology with pros and cons. Which of data communication cable is more appropriate to design the local area network? Describe.5+3
Ans: Star topology and ring topology are two
common network architectures that are used to connect computers and other
devices in a network.
Here is a
comparison of star and ring topology, including their pros and cons:
Star topology: In a star topology, all devices are connected to a central hub. This hub typically serves as a repeater, amplifying the signal as it is transmitted from one device to another.
Pros:
i) Easy to install and
configure
ii) Easy to expand by
adding additional device.
iii) Devices can be
easily added or removed without disrupting the network
iv) If one device
fails, it does not affect the rest of the network
Cons:
i) Requires a central hub or switch, which can be a single point of failure
ii) The central hub can
become a bottleneck if there is a lot of traffic
iii) More expensive to
implement, as each device requires a separate connection to the hub
Ring topology:
In a ring topology, all devices are connected in a circular configuration, with
each device connected to two other devices on either side of it. Data is
transmitted around the ring in one direction, with each device serving as a
repeater to amplify the signal as it is passed along.
Pro:
i) Easy to install and
configure.
ii) Easy to expand by
adding additional device.
iii) Devices can be easily
added or removed without disrupting the network
iv) Data can be transmitted
quickly, as it only needs to pass through one device to reach its destination
Cons:
i) If one device fails, it can disrupt the entire network
ii) More difficult to
troubleshoot and diagnose problems
iii) Limited in the number
of devices that can be connected, as the signal needs to be passed through each
device in the ring
To determine which communication media is most suitable for your local area network (LAN), you should consider several factors, including the distance, data rate, noise immunity, and cost.
If your LAN is relatively small and only covers a short distance,
twisted pair cables may be a suitable choice. These cables are relatively
inexpensive and can transmit data at speeds of up to 100 Mbps. However, they
are more susceptible to interference from electrical and magnetic fields and
may not be suitable for environments with a lot of electrical noise.
If your LAN covers a slightly longer distance or requires faster data
rates, coaxial cables may be a better choice. These cables can transmit data at
speeds of up to 1 Gbps and are less susceptible to interference than twisted
pair cables. However, they are more expensive than twisted pair cables.
If your LAN covers a very long distance or requires the fastest possible
data rates, fiber optic cables may be the best choice. These cables are capable
of transmitting data at speeds of up to 100 Gbps and are immune to electrical
and magnetic interference. However, they are the most expensive type of
communication media.
Ultimately, the most suitable communication media for your LAN will
depend on your specific needs and budget. It may be necessary to consider a
combination of different media to meet the requirements of your network.
16.
What is structure? Write a program to input roll, name and age of 5 students
and display them properly using structure. (2+6)
Ans: In C
programming, a structure is a user-defined data type that allows you to group
together variables of different types under a single name. Structures are
similar to arrays, but they can store variables of different types, rather than
just a single type.
#include
<stdio.h>
#include
<string.h>
// Define a
structure to represent a student
struct student
{
int roll;
char name[50];
int age;
};
int main() {
// Declare an array of 5 students
struct student students[5];
// Input the details of each student
for (int i = 0; i < 5; i++) {
printf("Enter the details of
student:\n");
printf("Roll: ");
scanf("%d",
&students[i].roll);
printf("Name: ");
scanf("%s", students[i].name);
printf("Age: ");
scanf("%d",
&students[i].age);
}
// Display the details of each student
for (int i = 0; i < 5; i++)
{
printf("\nStudent %d:\n", i+1);
printf("Roll: %d\n",
students[i].roll);
printf("Name: %s\n", students[i].name);
printf("Age: %d\n",
students[i].age);
}
return 0;
}
OR
Write a
C program to enter ID, employee_name, and post of the employee and store them
in a data file named "emp.txt". Display each record on the screen in
an appropriate format.
#include
<stdio.h>
#include
<conio.h>
main()
{
int id;
char name[20],post[30];
FILE *fp;
fp=fopen("d:\\emp.txt","w+");
char c='y';
while(c=='y')
{
printf("Enter
ID:\n");
scanf("%d",&id);
printf("Enter
employee name:\n");
scanf("%s",name);
printf("Enter
post:\n");
scanf("%s",post);
printf(fp,"%d%s%s",id,name,post);
printf("Do you need
more record (press y)");
c=getche();
}
rewind(fp);
while(fscanf(fp,"%d%s%s",&id,name,post)!=EOF)
{
printf("\n%d\t%s\t%s",id,name,post);
}
fclose(fp);
}
Also Read
Computer science NEB grade 12 solved question model set of CDC
No comments:
Post a Comment