-->

NEB computer science 2081 questions and solutions

 NEB computer science 2081 questions with solutions

-----------------------------------------------------------------------------------------



 

NEB-GRADE XII
2081 (2024)

Computer Science                                                                                                                                            Sub.Code: 4281

(New course)

(For the regular and grade increment students whose first two digits of registration number starts from 78, 79 and 80)

Multiple Choice Questions [9x1=9]

Rewrite the correct option of each question in your same answer sheet.

Group 'A'

1. Which one of the followings given statement correct?

A) Select * from enp where eopid = 103;

B) Select from enp where eopid = 103;

C) Select eopid where enp = 103 from emp;

D) Select eopid where eopid = 103 and table = emp;

2. Which database system normally offers better performance for geographically dispersed users ?

A) Centralized database system B) Distributed database system

C) NoSQL database system           D) Relational database system

3. Which of the following is an example of a public IPV4 address?

A) 192.168.1.1                                                  B) 172.16.10.1

C) 10.10.10.10                                                  D) 203.0.113.10

4. What is the correct syntax for a 'for-loop' in JavaScript?

A) for (var i=0; i<5; i++){}                              B) for (i=0; i<5; i++) {}

C) for (var i=0; i<5) {}                                       D) for (var i<5; i++) {}

5.Which PHP function is commonly used to execute SQL queries on a database connection established using mysqli extension ?

A) mysqli_query()                                           B) pdo_query()

C) mysql_query()                                             D) pgsql_query()

 

6.What is the correct syntax to declare a structure in C?

A) struct { }                          B) define struct {}

) struct [ ]                             D) struct <name> {}

7. In C, which operator is used to get the address of a variable?

                A)*                                                         B) &

C)->                                                        D).

8. Which OOP feature allows a class to inherit properties and behavior from another class?

A) Inheritance                                                   B) Encapsulation

C) Polymorphism                                              D) Abstraction

9. Which model of SDLC is characterized by a linear progression of phases from requirements gathering to maintenance ?

A) Waterfall model                         B) Agile model

C) Spiral model                                  D) RAD model

Group 'B'

Short answer questions [5x5=25]

10. Evaluate the advantages of DBMS compared to traditional file-based data storage systems.

OR                                                                                                                                    [5]

How does Second Normal Form (2NF) differ from First Normal Form (INF), and what are the key benefits of achieving 2NF in database design? Explain.                                                                                                                                [2+3]

11. Write a JavaScript function that checks if a number is even or odd and print the result. [1+4]

OR

What is purpose of the mysqli_connect() function in PHP? Describe its usage and parameters. [2+3]

12. Write short note on class and object in OOPS with a real-word example.           [2.5+2.5]

13. How do various requirement gathering techniques help in achieving a careful grasp of user needs and system requirements during SDLC's analysis phase?                                                                                                                                      [5]

14. Give five examples of AI applications in the education.                                                                                                                              [5]

Group 'C'[12×8-16]

Long answer questions

15. How does the star network topology differ from the bus network topology in terms of its architectural layout and data transmission methodology in modern computing environments?[8]

 16. Write a C program that uses structures to represent details of five books title, author, publisher and price) and prints them out.                                                                                       [8]

OR

Discuss the concept of binary file handling in C programming and explain how putw() and getw() functions facilitate binary input/output operations. Give examples.                                                [8]

 ---------------------------------------------------------------------------------


Solutions:

 NEB computer science 2081 questions with solutions

-----------------------------------------------------------------------------------------



 

NEB-GRADE XII
2081 (2024)

Computer Science                                                                                                                                            Sub.Code: 4281

(New course)

(For the regular and grade increment students whose first two digits of registration number starts from 78, 79 and 80)

Multiple Choice Questions [9x1=9]

Rewrite the correct option of each question in your same answer sheet.

Group 'A'

1. Which one of the followings given statement correct?

A) Select * from enp where eopid = 103;

B) Select from enp where eopid = 103;

C) Select eopid where enp = 103 from emp;

D) Select eopid where eopid = 103 and table = emp;

2. Which database system normally offers better performance for geographically dispersed users ?

A) Centralized database system B) Distributed database system

C) NoSQL database system           D) Relational database system

3. Which of the following is an example of a public IPV4 address?

A) 192.168.1.1                                                  B) 172.16.10.1

C) 10.10.10.10                                                  D) 203.0.113.10

4. What is the correct syntax for a 'for-loop' in JavaScript?

A) for (var i=0; i<5; i++){}                              B) for (i=0; i<5; i++) {}

C) for (var i=0; i<5) {}                                       D) for (var i<5; i++) {}

5.Which PHP function is commonly used to execute SQL queries on a database connection established using mysqli extension ?

A) mysqli_query()                                           B) pdo_query()

C) mysql_query()                                             D) pgsql_query()

 

6.What is the correct syntax to declare a structure in C?

A) struct { }                          B) define struct {}

) struct [ ]                             D) struct <name> {}

7. In C, which operator is used to get the address of a variable?

                A)*                                                         B) &

C)->                                                        D).

8. Which OOP feature allows a class to inherit properties and behavior from another class?

A) Inheritance                                                   B) Encapsulation

C) Polymorphism                                              D) Abstraction

9. Which model of SDLC is characterized by a linear progression of phases from requirements gathering to maintenance ?

A) Waterfall model                         B) Agile model

C) Spiral model                                  D) RAD model

Group 'B'

Short answer questions [5x5=25]

10. Evaluate the advantages of DBMS compared to traditional file-based data storage systems.

Ans:-

Here are some advantages of DBMS over traditional file based system.

1. Redundancy is reduced

  • File-based systems: Often store the same data in multiple files (redundancy).

  • DBMS: Uses centralized control to minimize duplication through normalization and relational structure.

2. Data consistency and integrity
      File based system: It is difficult to maintain because data is stored in multiple places
      DBMS:Enforces rules (primary key,foreign key etc)to maintain integrity od data
3.data security
     File based system: It does not have inbuilt security system
    DBMS:It has security such as role based access,authentication,permission controls
4.Data sharing:
     File based system: It does not have inbuilt security system
    DBMS:It has security such as role based access,authentication,permission controls.
5.Backup and recovery:
     File based system: It has manual and error-prone backup process.
    DBMS:It has automated backup system with recovery tools.

OR                                                                                                                                    [5]

How does Second Normal Form (2NF) differ from First Normal Form (INF), and what are the key benefits of achieving 2NF in database design? Explain.                                                                                                                                [2+3]

Ans:-

To understand the difference between 1NF and 2NF, lets understand about them in detail with example.

1NF:

A table is said to  be in 1NF if it satisfies the following conditions.

1. If it contains no repeating fields such as phone1,phone2 in different columns.

2.If each column contains indivisible data i.e atomic or single valued data.

       StudentIDNameSubjects
         101RamMath, Science
         102SitaEnglish, Nepali
This is not in 1NF. because subjects contain multivalued data.  NOw converting this into 1NF,

                         StudentIDNameSubject
                          101RamMath
                         101RamScience
                        102SitaEnglish
                         102SitaNepali
2NF:- A table is said to be in 2NF if it satisfies the following conditions.
1. If it is in 1NF.
2. If all non-key attributes are fully functionally dependent on the entire primary key, not just part of it. i.e no partial dependency should be there.
 example:
StudentIDCourseIDStudentNameCourseName
1C101RamMath
2C102SitaScience

Here StudentID+CourseID is being primary key.In this table the filed CourseName is dependent on CourseID and StudentName is depedent on StudentID, not fully on both. So there is being partial dependency.

Now breaking this into tables such as

studentcourse

StudentIDCourseID
1C101
2C102

students

StudentIDStudentName
1Ram
2Sita

courses

CourseIDCourseName
C101Math
C102Science

So these tables are in 2NF.

key benefits of 2NF:

1.Eliminate partial dependency

2.reduces data redundancy

3.optimizes storage

4. improves query efficiency

11. Write a JavaScript function that checks if a number is even or odd and print the result. [1+4]

Ans:-

<script>

function checkEvenOrOdd() 

{

  let number = parseInt(prompt("Enter a number:"));

   if (number % 2 === 0)

   {

    console.log(number + " is even.");

  } 

  else

  {

    console.log(number + " is odd.");

  }

}

checkEvenOrOdd();

</script>



OR

What is purpose of the mysqli_connect() function in PHP? Describe its usage and parameters. [2+3]

Ans:-

The mysqli_connect() function is used to establish a connection to a MySQL database using the MySQLi (MySQL Improved) extension in PHP.

Syntax:

mysqli_connect(host, username, password, database, port, socket);

  Here, port and socket are optional.  all other parameters' meaning are given below.
ParameterDescription
hostThe hostname or IP address of the MySQL server (e.g., "localhost").
usernameMySQL username (e.g., "root").
passwordPassword for the MySQL user. Mostly it is empty.
databaseName of the database to connect to.


Example:

         <?php

$connection = mysqli_connect("localhost", "root", "", "school");

if (!$connection) {

    die("Connection failed: " . mysqli_connect_error());

}

echo "Connected successfully";

?>


12. Write short note on class and object in OOPS with a real-word example.           [2.5+2.5]

Ans:-

Class and Object in OOPS

In Object-Oriented Programming (OOP), classes and objects are fundamental concepts.

  • Class:
    A class is a blueprint or template for creating objects. It defines the properties (attributes) and behaviors (methods) that objects created from the class will have.

    • Example: A Car class might have properties like color, model, and speed, and methods like accelerate() and brake().

  • Object:
    An object is an instance of a class. It represents an entity with specific values for the class’s attributes and can perform actions defined by the class’s methods.

    • Example: A specific car like a "red Ferrari" is an object of the Car class.

Programming example in C++:

            class student{ private:int id; public:void getdatat(){ }} ;
            int main()
            {
                student obj;obj.getdata();
            }
    Here, obj is an object. student is a class.

13. How do various requirement gathering techniques help in achieving a careful grasp of user needs and system requirements during SDLC's analysis phase?                                                                                                                                      [5]

Ans:

During the Analysis Phase of the Software Development Life Cycle (SDLC), various requirement gathering techniques help in accurately understanding user needs and system requirements. Here's how they contribute:

  1. Interviews

    • Directly engaging with stakeholders helps collect specific requirements, clarify user expectations, and uncover potential issues early on.

  2. Surveys and Questionnaires

    • Efficient for gathering feedback from a large number of users, identifying common needs, preferences, and concerns.

  3. Use Cases and User Stories

    • These techniques describe how users interact with the system, ensuring a focus on user-centric features and functionality.

  4. Workshops

    • Collaborative sessions with stakeholders allow for deeper discussions, prioritization of requirements, and consensus-building on key features.

  5. Prototyping

    • Developing prototypes helps stakeholders visualize the system early, refine requirements, and identify missing or misunderstood features.


14. Give five examples of AI applications in the education.                                                                                                                              [5]

Ans:

Artificial Intelligence:

AI (Artificial Intelligence) refers to the capability of machines or software to simulate human intelligence. It involves the development of systems that can perform tasks such as learning, reasoning, problem-solving, and decision-making by analyzing data and adapting over time.

Its applications in the education are given below.

  1. Personalized Learning
    AI-driven systems analyze student performance and tailor content to individual learning styles and paces, helping students grasp concepts more effectively.

  2. Intelligent Tutoring Systems
    AI tutors provide real-time feedback and personalized assistance to students, helping them with subjects like math, science, and language by identifying areas of difficulty.

  3. Automated Grading
    AI can grade assignments and exams, especially for objective questions like multiple choice, short answers, and essays, reducing teachers' workload and providing faster feedback.

  4. Virtual Learning Assistants
    AI-powered chatbots or virtual assistants help students navigate courses, answer questions, and offer resources, making learning more accessible.

  5. Predictive Analytics
    AI uses data to predict student outcomes, such as identifying students at risk of underperforming, allowing for timely interventions and support.



Group 'C'[12×8-16]

Long answer questions

15. How does the star network topology differ from the bus network topology in terms of its architectural layout and data transmission methodology in modern computing environments?[8]

ans:-

Star topology:

In a Star Topology, all devices (nodes) are connected to a central hub or switch. Communication between devices always passes through this central device.



Transmission methodology:

In a modern transmission methodology, each device sends data to a central hub or switch, which then forwards it to the intended destination device. Unlike older shared communication systems, modern networks utilize switched communication that operates on a point-to-point basis. This approach significantly reduces data collisions, as each connection is given a dedicated communication path within the switch. As a result, there is minimal interference between devices.

Advantages of Star Topology

  1. Easy to Manage and Troubleshoot

    • Since each device is connected individually to the central hub/switch, it's easy to detect and fix issues.

  2. Fault Isolation

    • Failure in one cable or device doesn't affect the rest of the network.

Disadvantages of Star Topology

  1. Dependency on Central Hub/Switch

    • If the hub or switch fails, the whole network becomes inoperative.

  2. Higher Cost

    • Requires more cable length and additional hardware like switches or hubs, making it costlier than bus topology.


Bus topology:-

Bus topology is a network setup where all devices (nodes) are connected to a single central cable, called the bus or backbone. Data sent by a device is broadcasted along this cable and received by all connected devices.



Transmission mechanism:-

In broadcast transmission, data travels both ways on a shared bus, where all devices receive it, but only the intended one accepts it. The CSMA/CD protocol manages this by checking if the bus is free before sending. If two devices transmit at once, a collision occurs, prompting both to wait randomly before retrying.

Advantages of Bus Topology

  1. Cost-Effective

    • Requires less cabling compared to star topology. No need for extra devices like switches or hubs.

  2. Easy to Set Up

    • Simple layout and minimal hardware make it easy to install and configure, especially for small networks.

Disadvantages of Bus Topology

  1. Limited Scalability

    • Adding many devices can slow down the network and increase chances of collisions.

  2. Difficult Fault Detection

    • If a problem occurs, it's hard to identify the exact point of failure in the bus.

 16. Write a C program that uses structures to represent details of five books title, author, publisher and price) and prints them out.                                                                                       [8]

Ans:-
/*
Write a C program that uses structures to represent details of  five books title, author, publisher and price)  and prints them out. */
#include<stdio.h>
struct book
{
char b_title[100];
char b_author[100];
char b_publisher[100];
float b_price;
}a[5];
int main()
{
int i;
for(i=0;i<=4;i++)
{
printf("enter book title\n");
scanf("%s",&a[i].b_title);
printf("enter book author\n");
scanf("%s",&a[i].b_author);
printf("enter book publisher\n");
scanf("%s",&a[i].b_publisher);
printf("enter book price\n");
scanf("%f",&a[i].b_price);
}
printf("the records are:\n");
for(i=0;i<=4;i++)
{
printf("book title=%s\n",a[i].b_title);
printf("book author is=%s\n",a[i].b_author);
printf("book publisher is=%s\n",a[i].b_publisher);
printf("book price is=%f",a[i].b_price);
}
return 0;
}

OR

Discuss the concept of binary file handling in C programming and explain how putw() and getw() functions facilitate binary input/output operations. Give examples.                                                [8] 

    Ans:-                                                                        


Binary file handling:-
                               In C programming, binary file handling is the process of reading from or writing to files in binary mode. Unlike text files, binary files store data in the same format as in memory — not human-readable but more efficient for storing complex data structures.

Why Binary Files?

  • Faster access and processing.

  • Stores exact memory representation (good for structs).

  • Useful for multimedia, database, or large data applications

Example:
FILE *fp = fopen("student.dat", "wb");

In this example, the file 'stuent.data' stores data in binary format because we have used the mode 'wb'. Here 'b' stands for binary mode.


putw() and getw():

In C, putw() and getw() are simple functions used to write and read integers to/from a binary file. They are used for binary I/O and work directly with integer values.

Syntax:
int putw(int n, FILE *fp);   
int  variable=getw(FILE *fp);     

Example:-
#include<stdio.h>
int main()
{
FILE *k;
int number;
k= fopen("file.txt","wb+");
printf("enter number. To exit, press ctrl+z\n");
while(((scanf("%d",&number)))!=EOF)
{
putw(number,k);
}
rewind(k);
while((number=getw(k))!=EOF)
{
printf("%d\n",number);
}
printf("data read.");
fclose(k);
return 0;
}

NEB computer science 2080 questions and solutions

NEB 2080 computer science(regular)

--------------------------------------------------------------------------------------------------------------------------


NEB GRADE XII 2080 (2023)                                                                             Computer Science
(New course)                                                                                                                Full Marks: 50
Sub.Code: 4281                                                                                                            Time: 2 hrs.
(For students whose first two digits of registration number starts form 78 or 79) 
Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks

Very short answer questions.
Group 'A'        9x1=9
1. Which of the given sign is used as a shortcut for JQuery?
    A) the % sign
    C) the S sign
    B) the & sign
    D) the @sign
2. Which of the following is DMI. statement?
    A) Create B) Select C) Create view Alter   D)Drop

3. A collection of hyperlinked documents on the Internet is called:
     A) HTML B) webpage C) www   d) email system

4. Which of following IPV4 address valid?
    A) 192.168.1.1                        C) 257.2.5.1
    B) EEE.000.33.000                D) 202.70.71.262


5. Which jQuery method is used to hide selected elements?
        A) hide()            B) hide (on)
        C) invisible()     D) display (none)
6. Which function is used to connect to mySQL database?
    A) mySqli open()            B) mysqli_connect()
    C) var mysqli_query()     D) Smysqli_con()
7. Which of the following is true about FILE *pt?
        A) FILE is a keyword in c for representing files and fpt is a variable of FILE type
        B) FILE is a buffered Stream
        C) FILE is a Stream
        D) FILE is a structure and fpt is a pointer to the structure of FILE type
8. Which a SDLC phase is used to ensure quality software?
    A) implementation                     C) testing
    B) maintenance                         D) system study
9. Coaxial cable is an example of... 
    A) Communication software  B) Guided Transmission media 
    C) Unguided Transmission media D) All of them


Group 'B'
Short answer questions 5x5=25 

10. Explain the Relational Data model with example.
    OR
Write SQL DDL commands to execute the following task with
reference to the schema given below:
student_info (regno as integer, name as character (25), class integer, gender character (1), address character (5).

11. Define a syntax for database connectivity.
Write a server side scripting code to insert data into the table student having fields (first name, last name, mark and email:) Assume that server name="localhost", username="root", password="" database name="student DB". (1+4)
OR
Write a JavaScript code to calculate the factorial of a given number. 5 

12. How is even-driven program (or OOP) differing from procedural- oriented programming? Explain.  (5)
13. Explain the importance of the system testing of the system development life cycle (SDLC). (1+4)
14. What is cloud computing? Point out the advantage and disadvantage of cloud computing

Long answer questions
Group 'C'   8x2-16


15. What is network topology? Differentiate between guided (wire media) and unguided (wireless media) with example. (2+6)


16. Write the advantage of pointer. Write a C-program to enter the radius of a football and find the area of football by using user defined function. (3+5) 

OR

Define the structure. Write a C-program using structure to input staff id, name and the salary of 50 staffs. Display staff id, name and salary of those staff whose salary range from 25 thousand to 40 thousand. (2+6)



NEB 2080 computer science(supplementary)

----------------------------------------------------------


Sub.Code: 4281'B'

NEB-GRADE XII 2080 (2023)

Computer Science Time: 2 hrs.

Full Marks: 50

Grade Increment (Supplementary) Examination

Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.

Very short answer questions.9x1=9

Group 'A'

1. Which SQL keyword is used to retrieve data from a table?

a) SELECT

c) WHERE

b) FROM

d) JOIN

2. Which of the following principle apply to 2NF?

a) A table must have a primary key

b) All non-key attributes must be dependent on the primary key

c) All attributes must be atomic

  d) A table must have at least more than two attributes.

3. Which of the following is a device that connects two or more networks and can filter and forward network traffic based on its destination address?

a) Switch c) Hub   b) Router d) Modem

4. Which JavaScript function use to text input?

a) alert()    b) prompt()     c) confirm()      d) console.log()

5. Which of the following PHP functions is used to connect to a MySQL database?

a) mysql_connect()

c) pdo_connect()

b) mysqli_connect()

d) db_connect()

6. What is the correct way to open a file named "data.txt" in C for reading?

a) fopen("data.txt", "r");

b) fopen("data.txt", "w");

c) fopen("data.txt", "a");

d) fopen("data.txt", "rb");

7. Which of the following concepts in object-oriented programming refers to binding data and function into a single unit.

a) Encapsulation

c) Polymorphism

b) Abstraction

d) Inheritance


8. What does the term "QA" stand for in the software development process?

a) Quality Assurance

c) Quality Assessment

b) Quality Analysis

d) Quantity Assurance

9. What type of communication technology is commonly used in IoT devices?

a) Wi-Fi

b) Bluetooth

c) Zigbee

d) All of the above


Group 'B'

Short answer questions 5x5=25

10. Describe the second normal form (2NF) with an example.

OR

What are the importance of database security in database management systems? Describe.

11. How do you add an event handler in JavaScript? Give an example.

OR

Explain the database connection PHP function for MySQL.

12. Describe the object and class in OOPS with an example. 

13. Explain the agile software development methodology in brief. 

14. Give any five examples of AI related applications.


Long answer questions.2x8=16

Group 'C' 4+4

15. Compare the bus and star network topology. Which of the network cable is suitable to design star topology in the school's network? Justify. 

16. Write a program to store five employees' records (EID, Name, post and I C department) and display them using structure.

OR

Describe file handling modes on C. Write a C program to create and write data into a file.  4+4






------------------------------------------------------------------------------------------------------------------------------------




Solutions

NEB 2080 computer science(regular)

--------------------------------------------------------------------------------------------------------------------------


NEB GRADE XII 2080 (2023)                                                                             Computer Science
(New course)                                                                                                                Full Marks: 50
Sub.Code: 4281                                                                                                            Time: 2 hrs.
(For students whose first two digits of registration number starts form 78 or 79) 
Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks

Very short answer questions.
Group 'A'        9x1=9
1. Which of the given sign is used as a shortcut for JQuery?
    A) the % sign
    C) the S sign
    B) the & sign
    D) the @sign
2. Which of the following is DMI. statement?
    A) Create B) Select C) Create view Alter   D)Drop

3. A collection of hyperlinked documents on the Internet is called:
     A) HTML B) webpage C) www   d) email system

4. Which of following IPV4 address valid?
    A) 192.168.1.1                        C) 257.2.5.1
    B) EEE.000.33.000                D) 202.70.71.262


5. Which jQuery method is used to hide selected elements?
        A) hide()            B) hide (on)
        C) invisible()     D) display (none)
6. Which function is used to connect to mySQL database?
    A) mySqli open()            B) mysqli_connect()
    C) var mysqli_query()     D) Smysqli_con()
7. Which of the following is true about FILE *pt?
        A) FILE is a keyword in c for representing files and fpt is a variable of FILE type
        B) FILE is a buffered Stream
        C) FILE is a Stream
        D) FILE is a structure and fpt is a pointer to the structure of FILE type
8. Which a SDLC phase is used to ensure quality software?
    A) implementation                     C) testing
    B) maintenance                         D) system study
9. Coaxial cable is an example of... 
    A) Communication software  B) Guided Transmission media 
    C) Unguided Transmission media D) All of them


Group 'B'
Short answer questions 5x5=25 

10. Explain the Relational Data model with example.
Ans:-
Relational database model:
The Relational Data Model is one of the most widely used models in database systems. It organizes data into tables, also known as relations, where each table consists of rows (called tuples) and columns (called attributes). Each table represents a specific type of entity — for example, a Students table might store information about students, with each row representing one student and each column representing details like name, age, or department.

A key feature of the relational model is the use of keys. A primary key uniquely identifies each record in a table, while a foreign key establishes a relationship between two tables.
StudentIDNameAgeDeptID
1Ram18D1
2Sita19D2
3Hari20D1
Here, StudentID is a primary key. Other fields are Name,age,DeptID. Rows are records.
      
    OR
Write SQL DDL commands to execute the following task with
reference to the schema given below:
student_info (regno as integer, name as character (25), class integer, gender character (1), address character (5).

Ans:-
CREATE TABLE student_info (
    regno int,
    name varchar(25),
    class int,
    gender char(1),
    address varchar(5)
);


11. Define a syntax for database connectivity.
Write a server side scripting code to insert data into the table student having fields (first name, last name, mark and email:) Assume that server name="localhost", username="root", password="" database name="student DB". (1+4)

Ans:-
Syntax for database connectivity:
$connection = new mysqli("server_name", "username", "password", "database_name");

or
$connection =  mysqli_connect("server_name", "user_name", "password", "database");

second part:-
<?php
$connection = mysqli_connect("localhost", "root", "", "studentDB");
if (!$connection) 
{
    die("Connection failed: " . mysqli_connect_error());
}
$firstname = "Ram";
$lastname = "Sharma";
$mark = 85;
$email = "ram@example.com";
$sql = "INSERT INTO student (firstname, lastname, mark, email)
        VALUES ('$firstname', '$lastname', $mark, '$email')";
if (mysqli_query($connection, $sql)) 
{
    echo "Record inserted successfully.";
else
 {
    echo "Error: " . $sql . "<br>" . mysqli_error($connection);
}
mysqli_close($connection);
?>

OR
Write a JavaScript code to calculate the factorial of a given number. 5 

Ans:-
<script>
  let number = parseInt(prompt("Enter a number:"));
  let f=1;
  let i;
  for(i=1;i<=number;i++)
  {
  f=f*i;
  }
  console.log("factorial value=",f);
</script>


12. How is even-driven program (or OOP) differing from procedural- oriented programming? Explain.  (5)
Ans:
Object Oriented Programming:-
he major motivating factor in the invention of object oriented is to remove some of the flaws encountered in the procedural oriented approach. Object oriented programming uses concept of “Object” and treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it, and protects it from accidental modifications from outside functions.

Features:-

1) Emphasis is on data rather than procedures or algorithms.

2) Programs are divided into what are known as objects.

3) Data structures are designed such that characterize the objects.

4) Functions that operate on the data are tied together in the data structure.

5) Data is hidden and cannot be accessed by external functions.

6) Objects may communicate with each other through functions.

7) New data and functions can be easily added whenever necessary.

8) Follows bottom-up approach in program design.


Procedural Oriented Programming:-
Procedural-Oriented Programming (POP) is a programming paradigm where the logic of the program is built around procedures or functions. It follows a top-down approach, meaning that the execution of the program starts from the main function and proceeds in a sequential manner. In POP, the primary focus is on the functions that manipulate data, which is typically stored in global variables.
Features:- 

1) Emphasis is on doing things(algorithms).

2) Large programs are divided into smaller programs known as functions.

3) Most of the functions share global data.

4) Data more openly around the system from function to function.

5) Functions transform data from one form to another.

6) Employs a top-down approach in program design.

  • Examples: C, Pascal, early BASIC.


  • 13. Explain the importance of the system testing of the system development life cycle (SDLC). (1+4)
    Ans:-
    System testing:-

    System Testing plays a crucial role in the System Development Life Cycle (SDLC) because it ensures that the software functions as expected and meets both the technical and business requirements. It's the phase where the entire system is tested as a whole to check for any issues, bugs, or gaps in functionality before the system is released to the users. 

    Below are the key reasons why System Testing is important:


    1. Ensures Quality and Reliability

    2. Identifies Bugs and Defects

    3. Validates Business Requirements

    4. Verifies Compatibility
    5. Performance and Load Testing

    Its types can be functional testing,integration testing,performance testing etc.

    14. What is cloud computing? Point out the advantage and disadvantage of cloud computing
    Ans:-
    Cloud computing:-
    Cloud Computing is the delivery of computing services (including storage, processing power, databases, networking, software, and more) over the internet rather than from a local server or personal computer. The term "cloud" refers to the internet, and cloud computing enables users to access and store data on remote servers, rather than relying on physical hardware or on-site IT infrastructure.
    The major players in cloud computing include Amazon Web Services (AWS), Microsoft Azure, Google Cloud, and others.



    Advantages:

    1.Cost-Efficiency:
       Users only pay for the services they use, reducing the need for large capital expenditures for hardware and infrastructure.
    2.Scalability and Flexibility:
    Cloud services can be scaled up or down quickly based on demand, ensuring that companies can meet fluctuating workloads without investing in excess hardware.

    Disadvantages:

    1.Data Security and Privacy Concerns:

    • Storing sensitive data on remote servers raises concerns about data breaches, hacking, or unauthorized access.

    2.Downtime and Service Interruptions:

    • Cloud services are susceptible to service outages. If the cloud provider experiences a failure, users may be unable to access their data or services until the issue is resolved.


    Long answer questions
    Group 'C'   8x2-16


    15. What is network topology? Differentiate between guided (wire media) and unguided (wireless media) with example. (2+6)
    Ans:-
    Network topology:

    Network Topology refers to the arrangement or structure of different elements (links, nodes, devices, etc.) in a computer network. It defines how various devices in a network are connected and how data flows within the network. There are several types of network topologies, including bus, star, ring, mesh, hybrid, and others, and the choice of topology affects the performance, scalability, and reliability of the network.

    Difference between guided and unguided media:
      To understand the differences between  guided and unguided media, here i have written the explanation of both. Let's go through it.

    Guided (Wired Media):

    Guided media refers to physical transmission mediums where data is transmitted via wires or cables, which guide the signal along a specific path. This type of medium requires a physical connection between devices in the network.


    • Examples:

      • Twisted Pair Cable (e.g., Ethernet cables used in local area networks).

      • Coaxial Cable (used in cable internet connections).

      • Fiber Optic Cable (used for high-speed, long-distance communication).

    • Characteristics:

      1. Physical medium: Data is transmitted through physical cables.

      2. Limited distance: The data transmission distance is limited by the type of cable used.

      3. Stable connection: Provides more stable and reliable communication compared to wireless media.

      4. Higher security: Since the signals are confined to the physical medium, there is less chance of unauthorized interception.

      5. Requires installation: Physical installation of cables is necessary, which can be time-consuming and costly.

    Unguided (Wireless Media):

    Unguided media refers to the transmission of data through air or space using electromagnetic waves, without the need for physical cables or wires. It is often referred to as wireless communication.


    • Examples:

      • Radio Waves (used in broadcast radio and wireless LANs).

      • Microwaves (used in satellite communications and point-to-point networks).

      • Infrared (IR) (used in remote control devices).

      • Wi-Fi (used in wireless networking for connecting devices).

    • Characteristics:

      1. No physical medium: Data is transmitted through the air using electromagnetic signals.

      2. Greater range: Wireless communication allows data transmission over larger areas, especially with advanced technologies like satellite or cellular networks.

      3. Mobility: Devices can move freely within the coverage area without being restricted by physical cables.

      4. Prone to interference: Wireless signals can be affected by various factors such as weather conditions, physical obstructions, and other devices operating on the same frequency.

      5. Lower security: Wireless signals are more vulnerable to interception, and extra security measures such as encryption are needed to prevent unauthorized access.



    16. Write the advantage of pointer. Write a C-program to enter the radius of a football and find the area of football by using user defined function. (3+5) 
    Ans:-
    Pointer and its advantages:

    A pointer is a variable that stores the memory address of another variable. Instead of holding a data value directly, a pointer "points to" the location in memory where the value is stored.

    In C, pointers are declared using the asterisk (*) symbol.

    Example: int *p; //p is a pointer

    advantages:
    • They allow efficient memory management by enabling dynamic allocation and deallocation of memory during runtime.
    •  Pointers also lead to faster program execution as they offer direct access to memory locations. 
    • One key advantage is that pointers support call by reference, allowing functions to modify the actual values of variables passed to them. 
    • They are essential in implementing advanced data structures such as linked lists, trees, stacks, and queues.
    Second part:-
    #include <stdio.h>
    void calculateArea();

    int main() 
    {
        calculateArea();
        return 0;
    }
    void calculateArea() 
    {
       float radius, area;
        printf("Enter the radius of the football: ");
        scanf("%f", &radius);
        area = 4 * 3.14 * radius * radius;;
        printf("The surface area of the football is: %.2f square units\n", area);
    }

    OR

    Define the structure. Write a C-program using structure to input staff id, name and the salary of 50 staffs. Display staff id, name and salary of those staff whose salary range from 25 thousand to 40 thousand. (2+6)

    Ans:-
    structure:-

    Structure:-

    Structure is a user defined data type available in C that allows to combine data items of different kinds.

    Structures are used to represent a record. Suppose we want to keep track of your books in a library. we might want to track the following attributes about each book −

    • Title

    • Author

    • Subject

    • Book ID

    For this, structure is helpful.

    Features:-

    1. We can copy items of one structure to another using = operator.

    2. We can use structure in nested form.

    3. We can pass the entire structure to a function.

    4. We can create an array for a given structure.

    Syntax:

    struct tag name

    {

    Data type member 1;

    Data type member2;

    } variable;


    Example: 

    struct book

    {

    Char b_name[100];

    Char b_authro[100];

    float b_price;

    }v;


    second part:-
    #include<stdio.h>
    struct staff
    {
    int staff_id;
    char staff_name[200];
    float staff_salary;
    };
    int main()
    {
    struct staff v[50];
    int i;
    for(i=0;i<=4;i++)
    {
    printf("enter staff id\n");
    scanf("%d",&v[i].staff_id);
    printf("enter staff name\n");
    scanf("%s",&v[i].staff_name);
    printf("enter staff salary\n");
    scanf("%f",&v[i].staff_salary);
    }
    printf("the records are:\n");
    for(i=0;i<=4;i++)
    {
    if(v[i].staff_salary>=25000 && v[i].staff_salary<=40000)
    {
    printf("staff id=%d\n",v[i].staff_id);
    printf("staff  name=%s\n",v[i].staff_name);
    printf("staff salary=%f\n",v[i].staff_salary);
    }
    }
    return 0;
    }

    NEB 2080 computer science(supplementary)

    ----------------------------------------------------------



    Sub.Code: 4281'B'

    NEB-GRADE XII 2080 (2023)

    Computer Science Time: 2 hrs.

    Full Marks: 50

    Grade Increment (Supplementary) Examination

    Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.

    Very short answer questions.9x1=9

    Group 'A'

    1. Which SQL keyword is used to retrieve data from a table?

    a) SELECT

    c) WHERE

    b) FROM

    d) JOIN

    2. Which of the following principle apply to 2NF?

    a) A table must have a primary key

    b) All non-key attributes must be dependent on the primary key

    c) All attributes must be atomic

      d) A table must have at least more than two attributes.

    3. Which of the following is a device that connects two or more networks and can filter and forward network traffic based on its destination address?

    a) Switch c) Hub   b) Router d) Modem

    4. Which JavaScript function use to text input?

    a) alert()    b) prompt()     c) confirm()      d) console.log()

    5. Which of the following PHP functions is used to connect to a MySQL database?

    a) mysql_connect()

    c) pdo_connect()

    b) mysqli_connect()

    d) db_connect()

    6. What is the correct way to open a file named "data.txt" in C for reading?

    a) fopen("data.txt", "r");

    b) fopen("data.txt", "w");

    c) fopen("data.txt", "a");

    d) fopen("data.txt", "rb");

    7. Which of the following concepts in object-oriented programming refers to binding data and function into a single unit.

    a) Encapsulation

    c) Polymorphism

    b) Abstraction

    d) Inheritance


    8. What does the term "QA" stand for in the software development process?

    a) Quality Assurance

    c) Quality Assessment

    b) Quality Analysis

    d) Quantity Assurance

    9. What type of communication technology is commonly used in IoT devices?

    a) Wi-Fi

    b) Bluetooth

    c) Zigbee

    d) All of the above


    Group 'B'

    Short answer questions 5x5=25

    10. Describe the second normal form (2NF) with an example.

    Ans:-

    2NF:- A table is said to be in 2NF if it satisfies the following conditions.
    1. If it is in 1NF.
    2. If all non-key attributes are fully functionally dependent on the entire primary key, not just part of it. i.e no partial dependency should be there.
     example:

    StudentIDCourseIDStudentNameCourseName
    1C101RamMath
    2C102SitaScience

    Here StudentID+CourseID is being primary key.In this table the filed CourseName is dependent on CourseID and StudentName is depedent on StudentID, not fully on both. So there is being partial dependency.

    Now breaking this into tables such as

    studentcourse

    StudentIDCourseID
    1C101
    2C102

    students

    StudentIDStudentName
    1Ram
    2Sita

    courses

    CourseIDCourseName
    C101Math
    C102Science

    So these tables are in 2NF.

    key benefits of 2NF:

    1.Eliminate partial dependency

    2.reduces data redundancy

    3.optimizes storage

    4. improves query efficiency

    OR

    What are the importance of database security in database management systems? Describe.

    Ans:-

    Database security plays a crucial role in protecting the data stored in a database management system (DBMS). As databases often contain sensitive, valuable, or confidential information, it is essential to ensure that only authorized users can access and manipulate the data.

    The key reasons why database security is important are:

    • Protects Sensitive Data:
      Database security ensures that personal, financial, or confidential information (such as user credentials, bank details, or organizational secrets) is protected from unauthorized access, leaks, or breaches.

    • Prevents Data Loss or Corruption:
      Security mechanisms such as backup and recovery systems help protect data from being accidentally deleted, modified, or corrupted due to malicious activities or software bugs.

    • Maintains Data Integrity:
      Security ensures that the data remains accurate and consistent over its lifecycle. It prevents unauthorized changes that could lead to data tampering or integrity loss.

    • Ensures Access Control:
      Through authentication and authorization techniques, security systems control who can access the database and what actions they are allowed to perform (such as read, write, or delete).

    • Protects Against Cyber Threats:
      Database security protects against various threats like SQL injection, malware, phishing, and ransomware attacks, which can exploit vulnerabilities to steal or destroy data.


    11. How do you add an event handler in JavaScript? Give an example.

    Ans:-

    In JavaScript, an event handler is a function that runs when a specific event occurs (like a button click, mouse movement, key press, etc.).

    Example:

    <!DOCTYPE html> <html> <head> <title>Event Handler Example</title> </head> <body> <button onclick="myBtn()">Click Me</button> <script> function myBtn() { alert("Button was clicked!"); } </script> </body> </html>


    OR

    Explain the database connection PHP function for MySQL.

    Ans:-

    To connect a PHP script with a MySQL database, we commonly use the mysqli_connect() function. This function allows PHP to communicate with the MySQL server.

    Syntax:

    mysqli_connect(servername, username, password, dbname);

    Parameters:
    servername: Usually "localhost" if the database is on the same server.
    username: MySQL username (commonly "root" in local setup).
    password: The password for the MySQL user (can be empty in XAMPP).
    dbname: Name of the database to connect to.

    Example:

    <?php $servername = "localhost"; $username = "root"; $password = ""; $database = "student"; $conn = mysqli_connect($servername, $username, $password, $database); if (!$conn)

    { die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; ?>



    12. Describe the object and class in OOPS with an example. 

    Ans:-


    Class and Object in OOPS
    Class:

    • class is a blueprint or template for creating objects. It defines the properties (attributes) and behaviors (methods) that objects created from the class will have.

      • Example: A Car class might have properties like colormodel, and speed, and methods like accelerate() and brake().

    Object:
    • An object is an instance of a class. It represents an entity with specific values for the class’s attributes and can perform actions defined by the class’s methods.

      • Example: A specific car like a "red Ferrari" is an object of the Car class.

    Programming example in C++:

                class student{ private:int id; public:void getdatat(){ }} ;
                int main()
                {
                    student obj;obj.getdata();
                }
        Here, obj is an object. student is a class.

    13. Explain the agile software development methodology in brief. 

    Ans:-

    Agile development model:
    Agile software development is a modern and flexible approach to building software that emphasizes incremental progress, collaboration, and adaptability. Unlike traditional methods (like the Waterfall model), Agile breaks the project into small, manageable parts called iterations or sprints, usually lasting 1–4 weeks.

    Each sprint results in a working version of the software, allowing teams to get frequent feedback, make changes quickly, and deliver high-quality products faster. Agile promotes continuous improvement, teamwork, and customer involvement throughout the development process.


    Key Principles of Agile:
    1. Customer collaboration over contract negotiation
    2. Responding to change over following a plan
    3. Working software over comprehensive documentation
    4. Individuals and interactions over processes and tools
    Benefits of Agile:
    • Faster delivery of features

    • Increased customer satisfaction

    • Greater flexibility and adaptability

    • Better risk management

    • Improved team communication

    14. Give any five examples of AI related applications.

    Ans:-
    Here are five examples of AI-related applications, explained in brief:

    1. Virtual Assistants (e.g., Siri, Alexa, Google Assistant)

    These AI-powered tools understand voice commands and perform tasks like setting reminders, playing music, answering questions, or controlling smart home devices.
    2. Recommendation Systems (e.g., Netflix, Amazon, YouTube)

    AI analyzes user behavior and preferences to suggest relevant movies, products, or videos, enhancing user experience and increasing engagement.
    3. Self-Driving Cars (e.g., Tesla Autopilot)

    Autonomous vehicles use AI algorithms to process data from sensors, detect obstacles, follow traffic rules, and make driving decisions without human input.
    4. Chatbots and Customer Support (e.g., Website Chat Support)

    AI chatbots provide instant replies to customer queries, reducing the need for human agents and improving customer service efficiency.
    5. Facial Recognition Systems

    Used in security, smartphones, and surveillance, AI-powered facial recognition systems can detect and verify individuals based on facial features.


    Long answer questions.2x8=16

    Group 'C' 4+4

    15. Compare the bus and star network topology. Which of the network cable is suitable to design star topology in the school's network? Justify. 

    Ans:-

    comparison of star and bus topology:

    Star topology:

    In a Star Topology, all devices (nodes) are connected to a central hub or switch. Communication between devices always passes through this central device.



    Transmission methodology:

    In a modern transmission methodology, each device sends data to a central hub or switch, which then forwards it to the intended destination device. Unlike older shared communication systems, modern networks utilize switched communication that operates on a point-to-point basis. This approach significantly reduces data collisions, as each connection is given a dedicated communication path within the switch. As a result, there is minimal interference between devices.

    Advantages of Star Topology

    1. Easy to Manage and Troubleshoot

      • Since each device is connected individually to the central hub/switch, it's easy to detect and fix issues.

    2. Fault Isolation

      • Failure in one cable or device doesn't affect the rest of the network.

    Disadvantages of Star Topology

    1. Dependency on Central Hub/Switch

      • If the hub or switch fails, the whole network becomes inoperative.

    2. Higher Cost

      • Requires more cable length and additional hardware like switches or hubs, making it costlier than bus topology.


    Bus topology:-

    Bus topology is a network setup where all devices (nodes) are connected to a single central cable, called the bus or backbone. Data sent by a device is broadcasted along this cable and received by all connected devices.



    Transmission mechanism:-

    In broadcast transmission, data travels both ways on a shared bus, where all devices receive it, but only the intended one accepts it. The CSMA/CD protocol manages this by checking if the bus is free before sending. If two devices transmit at once, a collision occurs, prompting both to wait randomly before retrying.

    Advantages of Bus Topology

    1. Cost-Effective

      • Requires less cabling compared to star topology. No need for extra devices like switches or hubs.

    2. Easy to Set Up

      • Simple layout and minimal hardware make it easy to install and configure, especially for small networks.

    Disadvantages of Bus Topology

    1. Limited Scalability

      • Adding many devices can slow down the network and increase chances of collisions.

    2. Difficult Fault Detection

      • If a problem occurs, it's hard to identify the exact point of failure in the bus.

    SEcond part:-

    The most suitable cable to design a star topology in a school network is the Unshielded Twisted Pair (UTP) cable, specifically Cat5e or Cat6.
    Because of the following reasons.
    Cost-effective:
    UTP cables are inexpensive and readily available, making them ideal for educational institutions with budget constraints.
    Easy to Install and Manage:
    UTP cables are lightweight and flexible, which makes them easier to install and maintain in classrooms and labs.
    Good Speed and Performance:
    Cat5e supports speeds up to 1 Gbps.
    Cat6 supports up to 10 Gbps over shorter distances, suitable for modern school networks with high-speed internet.
    Compatibility with Networking Devices:
    UTP cables are compatible with switches, routers, hubs, and other devices used in star topology.
    Reliable for Indoor Use:
    Since schools usually have controlled indoor environments, UTP cables work well without needing additional shielding.


    16. Write a program to store five employees' records (EID, Name, post and I C department) and display them using structure.

    Ans:-

    #include<stdio.h> struct employees { int emp_id; char emp_name[100]; char emp_post[100]; char emp_dept[100]; }v[5]; int main() { int i; for(i=0;i<=4;i++) { printf("enter employee id\n"); scanf("%d",&v[i].emp_id); printf("enter employee name\n"); scanf("%s",&v[i].emp_name); printf("enter employee post\n"); scanf("%s",&v[i].emp_post); printf("enter employee department\n"); scanf("%s",&v[i].emp_dept); } printf("the records are:\n"); for(i=0;i<=4;i++) { printf("employee id=%d\n",v[i].emp_id); printf("employee name=%s\n",v[i].emp_name); printf("employee post=%s\n",v[i].emp_post); printf("employee department=%s\n",v[i].emp_dept); } return 0; }

    OR

    Describe file handling modes on C. Write a C program to create and write data into a file.  4+4


    Ans:
    File handling modes:

    In C programming, file handling is done using different modes that define how a file should be opened — for reading, writing, or appending.

    Here are the commonly used file modes:

    ModeDescription
    "r"Opens a file for reading only. File must exist.
    "w"Opens a file for writing only. If file exists, content is erased; if not, it is created.
    "a"Opens a file for appending. Data is added at the end. File is created if it doesn't exist.
    "r+"Opens a file for reading and writing. File must exist.
    "w+"Opens a file for reading and writing. Erases content if file exists or creates a new one.
    "a+"Opens a file for reading and appending. File is created if it doesn't exist.
    Example:
    FILE *fp;
    fp = fopen("data.txt", "r");
    or
    FILE *fp;
    fp = fopen("data.txt", "r+");


    Second part:-
    #include<stdio.h>
    int main()
    {
    FILE *p;
    char string[200]="hello, how are u?";
    p=fopen("file.txt","w");
    fprintf(p,"%s",string);
    fclose(p);
    printf("the data stored successfully");
    return 0;
    }