NEB 12 COMPUTER SCIENCE : A COMPLETE BOOKLET TO UNDERSTAND EVERYTHING IN COURSE INCLUDE MCQ & TEST

NEB 12 Computer Science: Ultimate Masterclass

🎓 Welcome, Spandana Basnet & Buddha Chiring Gurung!

This is your 20-Part Journey to scoring top marks in the NEB Grade 12 Computer Science Board Exam. We will break down every difficult concept into simple English, and use Nepali to make the hardest words crystal clear. Let's build your foundation!

Part 1: The Foundation of Database Management System (DBMS)

In NEB Grade 12, the first and one of the most important chapters is the Database Management System. Before we write complex codes, we must understand how data is stored. Think of this chapter as learning how to build a massive digital library.

1. Data vs. Information (डाटा र इन्फर्मेसन बिचको फरक)

Many students confuse these two words. Let's make it easy:

  • Data (तथ्यांक): These are raw, unorganized facts that have no clear meaning on their own.
    Example: "85", "Spandana", "A+". (These words are scattered. What do they mean? We don't know.)
  • Information (जानकारी): When we process, organize, and structure the data so it makes sense, it becomes Information.
    Example: "Spandana scored 85 marks and got an A+ grade." (Now it has meaning!)

Formula to remember: Data + Processing = Information.

2. What is a Database and DBMS?

Database: An organized collection of related data so that it can be easily accessed, managed, and updated. Think of it as a smart, digital filing cabinet (व्यवस्थित फाइल राख्ने दराज).

DBMS (Database Management System): It is a software application that allows users to create, maintain, and control access to the database. It is the "Manager" of the database.

Popular DBMS Software: MySQL, Oracle, MS Access, Microsoft SQL Server.

3. Traditional File System vs. DBMS (पुरानो प्रणाली भन्दा DBMS किन राम्रो?)

Before DBMS was invented, companies used traditional file systems (like saving data in separate text files or Excel sheets). It was a disaster. Here is why DBMS is powerful and necessary:

  • Reduces Data Redundancy (डाटा दोहोरोपन कम गर्छ): In older systems, Buddha's phone number might be saved in the Library file and the Accounts file. If he changes his number, you have to update it in two places. DBMS keeps data in a central place, stopping duplicate data.
  • Removes Data Inconsistency (डाटा बाझिने समस्या हटाउँछ): If data is duplicated, mistakes happen. Buddha's old number might stay in the Library file while the new one is in Accounts. DBMS ensures all departments see the exact same, updated data.
  • High Security (उच्च सुरक्षा): DBMS allows you to set passwords. An accountant can see fees, but cannot change grades. A teacher can see grades, but cannot see fees.
  • Concurrent Access (एकै पटक धेरैले चलाउन मिल्ने): Thousands of students can check their NEB results at the exact same second without the system crashing.

🔍 Real-Life Case Study: Spandana and Buddha's Supermarket

Spandana and Buddha open a massive supermarket in Kathmandu. On day one, they use a traditional paper register (File System) to record sales.

The Problem: When 500 customers arrive, they have to flip through hundreds of pages to find product prices. If a product price changes, they have to manually erase and rewrite it everywhere. It is slow, redundant (दोहोरिएको), and highly insecure (anyone can read the register).

The Solution (DBMS): They install a DBMS. Now, all product prices are stored in a central digital database. When the cashier scans a barcode, the DBMS instantly pulls the price. When they update the price of an apple in the main office, it automatically updates on all 20 cash registers instantly. The data is consistent, secure, and incredibly fast!

📝 Board Exam Preparation (Target: A+)

Base Marks for Chapter 1: Generally, the DBMS chapter carries about 8 to 10 marks in the NEB final exam (including short questions, long questions, and MCQs).

VVI Questions from Part 1 to Memorize:

  1. Differentiate between Data and Information with suitable examples. (2 Marks)
  2. What is DBMS? List any four popular DBMS software. (3 Marks)
  3. Explain the limitations of the Traditional File Processing System and how DBMS overcomes them (Focus on Redundancy and Inconsistency). (5 Marks - Long Question)
🚀 End of Part 1!
Spandana and Buddha, read this carefully. When you have fully understood Data, Information, Redundancy, and Inconsistency, reply with:
"Start Part 2"
In Part 2, we will dive into Database Models (Relational, Network, Hierarchical) and Database Architecture!

NEB 12 Computer Science: Ultimate Masterclass

🚀 Welcome Back, Spandana & Buddha!

Great job completing Part 1! Now that you know why we use a Database, it's time to look under the hood. In Part 2, we will explore Database Architecture (how it is built) and Database Models (how the data is arranged). Pay close attention to the Relational Model—it's a guaranteed exam question!

1. Database Architecture (डाटाबेसको बनावट)

Database architecture defines how users connect to the database. Think of it as the design of a building. There are 3 main types:

A. 1-Tier Architecture

In this, the user, the application, and the database all live on the same single computer.
नेपालीमा: यदि तपाइँले आफ्नै ल्यापटपमा MS Access खोल्नुभयो र त्यहीँ डाटा सेभ गर्नुभयो भने त्यो 1-Tier हो। यो इन्टरनेटमा जोडिएको हुँदैन।

B. 2-Tier Architecture (Client-Server)

Here, the user has an Application (Client) on their computer, which talks directly to a Database Server somewhere else.
Analogy: Going to a shop and talking directly to the shopkeeper.
नेपालीमा: प्रयोगकर्ताले आफ्नो कम्प्युटरबाट सिधै डाटाबेस सर्भरसँग कुरा गर्छ।

C. 3-Tier Architecture (The Web Standard)

This adds a "Middle Man" (Application Server). The user only sees a Web Page (Client). The web page talks to the Application Server (Logic), and the Application Server talks to the Database.
Analogy: A Restaurant. The Customer (Client) talks to the Waiter (Application Server). The Waiter goes to the Kitchen (Database) to get the food. The customer never enters the kitchen! This is highly secure.

2. Database Models (डाटा सजाउने तरिकाहरू)

A Database Model dictates the logical structure of how data is saved and linked. How do we organize Buddha's info and Spandana's info?

A. Hierarchical Model (ट्री मोडल)

Data is organized in a Tree-like structure. It follows a Parent-Child relationship. A parent can have many children, but a child can only have ONE parent (1:N relationship).
नेपालीमा: यो ठ्याक्कै हाम्रो वंशज (Family Tree) जस्तै हुन्छ। हजुरबुबा -> बुबा -> छोरा।

B. Network Model (जालो मोडल)

This is an upgrade to the Hierarchical model. Here, data is represented as a Graph. A child can have multiple parents (Many-to-Many or N:M relationship). It is very complex to manage.

C. Relational Database Model (RDBMS) - 👑 The King!

This is the most important model in the world! Data is organized into simple 2D Tables consisting of Rows and Columns.

  • Table: Also called a Relation.
  • Row: Also called a Tuple or Record (It holds complete data of one person).
  • Column: Also called an Attribute or Field (It holds one specific type of data, like 'Age' or 'Name').
नेपालीमा: यसमा डाटाहरु Table (रो र कोलम) मा राखिन्छ जसले गर्दा बुझ्न र चलाउन एकदमै सजिलो हुन्छ। MySQL, Oracle सबै RDBMS हुन्।

3. Keys in Relational Database (साँचोहरू)

In RDBMS, we use "Keys" to identify records uniquely and link different tables together.

🔑 Primary Key (प्राथमिक साँचो)

It is a column (or set of columns) that uniquely identifies every row in a table.
Rules: It can NEVER be empty (Not Null), and it can NEVER be duplicated.
उदाहरण: Name प्राइमरी कि हुन सक्दैन किनकि दुई जनाको नाम 'Buddha' हुन सक्छ। तर Symbol Number वा Citizenship Number सधैं फरक हुन्छ, त्यसैले यो Primary Key हो।

🔗 Foreign Key (विदेशी साँचो)

It is a column in one table that points to the Primary Key of another table. It is used to link two tables together! (We will see this in the case study below).

🔍 Real-Life Case Study: Linking Data

Spandana and Buddha are designing a Database for FEEN Computer Classes. They create two Tables:

Table 1: STUDENTS
Columns: StudentID (Primary Key), Name, Address.
Data: [101, Spandana, KTM], [102, Buddha, PKR]

Table 2: FEES_PAID
Columns: ReceiptNo (Primary Key), Amount, StudentID (Foreign Key).
Data: [R001, Rs.5000, 101]

How it works: Look at Table 2. Instead of writing Spandana's full name and address again in the Fees table (which causes redundancy), they just write "101". This 101 is the Foreign Key that links back to the Primary Key in the Students table. If Buddha pays fees tomorrow, they just add [R002, Rs.5000, 102]. The tables are magically connected!

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 2 to Memorize:

  1. What is Database Architecture? Briefly explain 2-tier and 3-tier architecture. (5 Marks)
  2. Define Relational Database Model. Explain the terms: Tuple, Attribute, and Relation. (3 Marks)
  3. What is a Primary Key? How is it different from a Foreign Key? Give an example. (5 Marks - VERY IMPORTANT)
  4. Differentiate between Hierarchical and Network Database Models. (3 Marks)
🚀 End of Part 2!
Excellent focus, Spandana and Buddha! Take a break, review the Primary Key concept, and when you are completely ready, reply with:
"Start Part 3"
In Part 3, we will dive into Normalization (1NF, 2NF, 3NF)—the art of cleaning up messy data, and introduce SQL Commands (DDL & DML)!

NEB 12 Computer Science: Ultimate Masterclass

🚀 Excellent Progress, Spandana & Buddha!

Welcome to Part 3! Today we tackle two of the most famous topics in databases: Normalization (the art of cleaning messy data) and SQL Commands (how we actually talk to the database). Grab a notebook, because 1NF, 2NF, and 3NF are almost always asked in the NEB exams!

1. What is Normalization? (डाटा शुद्धीकरण)

Imagine your bedroom is a complete mess. Clothes, books, and shoes are all mixed together on the bed. What do you do? You organize them into proper drawers.
In databases, Normalization is the process of organizing data to minimize redundancy (duplicate data) and remove anomalies (errors when inserting, updating, or deleting).
नेपालीमा: Normalization भनेको एउटा ठूलो र भद्रगोल Table लाई टुक्र्याएर साना-साना र व्यवस्थित Tables बनाउने प्रक्रिया हो, जसले गर्दा डाटा दोहोरिने (Redundancy) समस्या हट्छ।

A. First Normal Form (1NF) - The Rule of Atoms

Rule: A table is in 1NF if every cell contains a single, atomic value. No multiple values are allowed in one box!

Example of Bad Data (Unnormalized): Buddha's phone number column has "9841... , 9851...".
Fixing it to 1NF: We split it into two separate rows. One row for his first number, and a new row for his second number.
सजिलो भाषामा: एउटा कोठा (Cell) भित्र दुइटा कुरा राख्न पाइँदैन। एउटा कोठामा एउटा मात्र डाटा हुनुपर्छ।

B. Second Normal Form (2NF) - Removing Partial Dependency

Rule: It must be in 1NF. PLUS, all non-key columns must depend on the entire Primary Key, not just a part of it (This happens when you have a composite primary key made of two columns).

Example: If a table has Primary Keys [Student_ID + Course_ID], and a column for "Student_Name". The "Student_Name" only depends on Student_ID, not the Course_ID! This is a Partial Dependency.
Fixing it to 2NF: Break it into two tables. Put Student_ID and Student_Name in one table, and Course_ID in another.

C. Third Normal Form (3NF) - Removing Transitive Dependency

Rule: It must be in 2NF. PLUS, there should be no Transitive Dependency. This means a non-key column cannot depend on another non-key column.

Example: Table has columns: [Employee_ID (Key), Department_ID, Department_Name].
Here, Department_Name depends on Department_ID. But Department_ID is NOT the primary key!
Fixing it to 3NF: (यसलाई हटाउन छुट्टै Table बनाउने) Create a separate "Department" table.

2. SQL Commands (Structured Query Language)

SQL is the language we use to communicate with Relational Databases (like MySQL or Oracle). SQL commands are broadly divided into categories. The two most important for your exam are DDL and DML.

A. DDL (Data Definition Language)

DDL commands are used to define or change the structure of the database (Tables, Views, Schemas). They do not deal with the data inside.
नेपालीमा बुझ्नुस्: DDL ले घरको नक्सा वा जग (Structure) बनाउने, भत्काउने वा परिवर्तन गर्ने काम गर्छ।

  • CREATE: To create a new database or table.
  • ALTER: To modify an existing table structure (e.g., adding a new column).
  • DROP: To completely delete a table and its structure from the database.

B. DML (Data Manipulation Language)

DML commands are used to manipulate the actual data inside the tables.
नेपालीमा बुझ्नुस्: DML ले घर बनिसकेपछि घरभित्र मान्छे वा सामान (Data) राख्ने, झिक्ने वा परिवर्तन गर्ने काम गर्छ।

  • INSERT: To add new rows of data into a table.
  • UPDATE: To modify existing data (e.g., changing Spandana's address).
  • DELETE: To remove specific rows of data.
  • SELECT: To retrieve or read data. (Note: Some modern textbooks call SELECT a DQL - Data Query Language, but historically it falls under DML. For NEB, grouping it as DML is acceptable unless specifically asked for DQL).

🔍 Real-Life Case Study: Spandana and Buddha Writing SQL

Spandana wants to create a table for their class. She uses DDL to build the structure:

CREATE TABLE Students (
    RollNo INT PRIMARY KEY,
    Name VARCHAR(50),
    Address VARCHAR(50)
);

Now, the table exists but it is empty. Buddha uses DML to put their data inside the table:

INSERT INTO Students (RollNo, Name, Address)
VALUES (1, 'Spandana', 'Kathmandu'),
       (2, 'Buddha', 'Pokhara');

If Buddha wants to see the data, he writes: SELECT * FROM Students;

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 3 to Memorize:

  1. What is Normalization? Explain 1NF, 2NF, and 3NF with examples. (5 or 8 Marks - HIGH CHANCE)
  2. What is SQL? Differentiate between DDL and DML commands with two examples of each. (5 Marks)
  3. Write the SQL syntax to CREATE a table and INSERT data into it. (3 Marks)
  4. What is Data Redundancy? How does Normalization help in reducing it? (3 Marks)
🚀 End of Part 3!
Incredible work! Take a deep breath. Memorize the difference between DDL (Structure) and DML (Data). When you are fully confident, reply with:
"Start Part 4"
In Part 4, we will finish our Database unit by exploring Centralized vs. Distributed Databases and how to secure our database!

NEB 12 Computer Science: Ultimate Masterclass

🌟 Fantastic Job, Spandana & Buddha!

You've mastered tables, keys, and SQL! Now, to wrap up the Database chapter in Part 4, we will look at how massive companies store their data across the world (Centralized vs. Distributed) and how they protect it from hackers (Database Security & DBA roles). Let's finish strong!

1. Centralized vs. Distributed Database

Where does the data actually live? The answer divides databases into two major types.

A. Centralized Database System (केन्द्रीकृत डाटाबेस)

In this system, all the data is stored, maintained, and managed at a single location (one physical server). Anyone who wants to access the data must connect to this central computer via an internet or network connection.

  • Pros: Very easy to manage, update, and secure because everything is in one room.
  • Cons (The Big Flaw): "Single Point of Failure" (एउटै ठाउँमा बिग्रे सबै बन्द हुने). If that one server catches fire or loses power, the entire system goes down worldwide.

B. Distributed Database System (वितरित डाटाबेस)

In this system, the database is not in one place. Parts of the database are stored across multiple physical locations (different cities or countries), connected together by a high-speed network. To the user, it feels like one single database.

  • Pros: High availability and reliability. If the Kathmandu server goes down, the Pokhara server keeps the system running! (एउटा सर्भर बिग्रिए पनि अर्कोले काम गर्छ). Faster access for local users.
  • Cons: Extremely complex to design and expensive to maintain.

2. Database Security & The DBA

Data is the most valuable asset in the modern world. Protecting it from unauthorized access, modification, or destruction is called Database Security.

Core Security Concepts:

  • Authentication (प्रमाणीकरण): Verifying who you are. (e.g., Using Username, Password, or Biometrics).
  • Authorization (अधिकार): Verifying what you are allowed to do. (e.g., A student can view grades, but only a teacher can edit them).
  • Encryption (गोप्यीकरण): Scrambling data into an unreadable format. Even if a hacker steals the database file, it looks like gibberish without the decryption key.
  • Backup and Recovery: Regularly copying data to a safe place so it can be restored if the main system crashes.

The DBA (Database Administrator) - The Boss!

A DBA is the IT professional responsible for the design, implementation, maintenance, and repair of an organization's database.
नेपालीमा: DBA भनेको डाटाबेसको मुख्य म्यानेजर हो जसले डाटाबेसलाई सुरक्षित राख्ने र सञ्चालन गर्ने जिम्मा लिन्छ।

Roles of a DBA:

  1. Installing and upgrading database software.
  2. Creating user accounts and granting access permissions.
  3. Taking regular backups of the data.
  4. Monitoring system performance and making it faster.

🔍 Real-Life Case Study: Expanding FEEN Supermarket

Spandana and Buddha's supermarket is a huge success! They now have 50 branches across Nepal.

At first, they used a Centralized Database in Kathmandu. But when the internet in Kathmandu went down, the cashiers in Pokhara and Chitwan couldn't scan items or make bills! The whole business stopped.

To fix this, Buddha, acting as the DBA, upgraded to a Distributed Database. He placed servers in Kathmandu, Pokhara, and Biratnagar. Now, if the Kathmandu server fails, the Pokhara branches automatically connect to their local server and keep working. Spandana also ensured Database Security by setting up Authorization rules so cashiers can only make bills, but branch managers can issue refunds.

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 4 to Memorize:

  1. Differentiate between Centralized and Distributed Database Systems. (5 Marks)
  2. What is Database Security? Explain the terms Authentication and Authorization. (3 Marks)
  3. Who is a DBA? List any four major responsibilities of a Database Administrator. (5 Marks - HIGH CHANCE)

🎉 Congratulations! You have now completed the entire Database Management System (DBMS) unit. This covers about 15-20% of your board exam!

🚀 End of Part 4 (End of Database Unit)!
Amazing dedication, Spandana and Buddha! You've built a rock-solid foundation. Take a moment to revise Chapters 1 to 4. When you are ready to jump into the exciting world of Networking and Telecommunication, reply with:
"Start Part 5"
In Part 5, we will learn how computers talk to each other, Network Topologies (Bus, Star, Ring), and Transmission Media!

NEB 12 Computer Science: Ultimate Masterclass

🌐 Welcome to the Digital World, Spandana & Buddha!

We have officially started a brand new chapter: Networking and Telecommunication! You know how to store data (Database), but how do you send that data from Kathmandu to New York in one second? Today, we learn how computers talk to each other, the cables they use, and how they sit in a room (Topologies).

1. Introduction to Computer Networks

A Computer Network is simply a group of two or more computers connected together. But why do we connect them? For one major reason: Resource Sharing (स्रोत र साधनको बाँडफाँड).

What do we share?

  • Hardware: Instead of buying 50 printers for 50 computers, you buy one printer, connect it to the network, and everyone shares it.
  • Software/Data: Sharing files, videos, or accessing a central database (like we learned in Part 4).
  • Communication: Emails, WhatsApp, video calls.

2. Transmission Media (डाटा पठाउने बाटो)

For data to travel from Spandana's computer to Buddha's computer, it needs a physical or invisible path. This path is called Transmission Media. It is divided into two types:

A. Guided Media (Wired / तारसहितको माध्यम)

Here, the data is guided along a physical physical wire or cable. The signal cannot escape the wire.

  • Twisted Pair Cable: The normal LAN cable (like the one plugged into your home Wi-Fi router). It has pairs of copper wires twisted together to cancel out noise. It is cheap but covers short distances.
  • Coaxial Cable: Think of your standard Dish TV cable. It has a thick copper core in the center. It carries higher bandwidth than twisted pair.
  • Fiber Optic Cable (फाइबर अप्टिक): The King of cables! Instead of electricity, it uses Light to send data through tiny glass tubes. It is the fastest media in the world, extremely secure, but very expensive and hard to repair.

B. Unguided Media (Wireless / ताररहित माध्यम)

Here, data travels through the air or empty space using electromagnetic waves. There is no physical wire.

  • Radio Waves: Used for AM/FM radio and standard Wi-Fi. They can easily pass through walls.
  • Microwaves: Used for mobile networks and point-to-point communication. They travel in a straight line, so antennas must face each other (Line of Sight).
  • Infrared: Used in TV remotes. It covers very short distances and cannot pass through walls.
  • Satellite: Used for global communication, GPS, and broadcasting over oceans.

3. Network Topology (कम्प्युटरहरू जोड्ने ढाँचा)

Topology refers to the physical or logical layout of a network. How are the computers arranged in a room? Let's look at the main types:

1. Bus Topology (बस टपोलोजी)

All computers are connected to a single, main cable called a Backbone.
Pros: Cheap and easy to set up.
Cons: If the main backbone cable breaks, the ENTIRE network dies. (मुख्य तार चुँडियो भने सबै बन्द हुन्छ).

2. Star Topology (स्टार टपोलोजी) - Most Popular!

Every computer connects to a central device called a Hub or Switch.
Pros: If one cable breaks, only that specific computer is disconnected. The rest of the network works perfectly. Easy to find faults.
Cons: If the central Switch fails, the whole network stops.

3. Ring Topology (रिङ टपोलोजी)

Each computer connects to exactly two other computers, forming a closed circle or ring. Data travels in one direction.
Cons: If one computer breaks down, the data cannot pass, and the whole ring crashes.

4. Mesh Topology (मेश टपोलोजी)

Every single computer is connected to every other computer directly with a separate cable.
Pros: Extremely reliable. If one cable breaks, data takes another path.
Cons: Requires too many cables, making it very expensive and messy.

5. Tree Topology

A combination of Bus and Star topologies. It looks like the branches of a tree.

🔍 Real-Life Case Study: Designing FEEN Computer Lab

Spandana and Buddha are given a contract to design a modern computer lab for FEEN with 30 computers.

Their Choice of Topology: They reject Bus Topology because if a rat bites the main cable, the whole lab stops. They reject Mesh Topology because buying 435 separate cables is too expensive! They choose Star Topology. They buy a central Switch, and every computer gets its own cable. If one student kicks their cable by accident, only their PC disconnects!

Their Choice of Media: Since the lab is inside one building, they don't need expensive Fiber Optics to every PC. They use Twisted Pair Cable (CAT6) to connect PCs to the switch. However, to get the main internet connection from Nepal Telecom outside the building, they request a Fiber Optic drop for maximum speed!

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 5 to Memorize:

  1. What is Transmission Media? Differentiate between Guided and Unguided media with examples. (5 Marks)
  2. Why is Fiber Optic cable considered better than Twisted Pair cable? Give two reasons. (2 Marks)
  3. Define Network Topology. Explain Star Topology and Bus Topology with their advantages and disadvantages. (5 or 8 Marks - HIGH CHANCE)
  4. Why is Mesh Topology highly reliable but rarely used in normal computer labs? (3 Marks)
🚀 End of Part 5!
Great job, Spandana and Buddha! You now know how to physically design a network. Take a short break to review the topologies. When you're ready to learn how the internet actually functions behind the scenes, reply with:
"Start Part 6"
In Part 6, we will conquer the hardest networking topic: The OSI Reference Model (All 7 Layers) and Network Devices (Switch vs. Router)!

NEB 12 Computer Science: Ultimate Masterclass

🧠 Brace Yourselves, Spandana & Buddha!

Welcome to Part 6! You are about to learn the most famous topic in networking: The OSI Reference Model. This is the theoretical blueprint of how the entire Internet works! We will also look at the hardware devices that operate at these different layers. Pay close attention, as this is a guaranteed long question in your NEB exams!

1. The OSI Reference Model (ओ.एस.आई. मोडल)

OSI stands for Open Systems Interconnection. It was developed by ISO in 1984. It is not a physical machine; it is a conceptual model that breaks down the complex process of sending data over a network into 7 smaller, manageable layers.
नेपालीमा: एउटा कम्प्युटरबाट अर्को कम्प्युटरमा डाटा कसरी पुग्छ भनेर बुझाउने सैद्धान्तिक खाका नै OSI Model हो। यसका ७ वटा तह (Layers) हुन्छन्।

How to Remember the 7 Layers? (Bottom to Top)

Use this simple trick: Please Do Not Throw Sausage Pizza Away!

Layer No. Layer Name What it does (Easy English & Nepali)
Layer 7 Application The screen you see! This layer interacts with software apps like Google Chrome, WhatsApp. Protocols: HTTP, FTP.
(तपाईंले चलाउने एप्स र सफ्टवेयर)
Layer 6 Presentation Translates data into a common format (like JPEG, ASCII). Also handles Data Encryption (hiding data) and Compression (making it small).
(डाटालाई अनुवाद, सानो र गोप्य बनाउने)
Layer 5 Session Establishes, maintains, and ends the connection (session) between two computers.
(दुई कम्प्युटर बिच सम्पर्क जोड्ने र तोड्ने)
Layer 4 Transport Breaks large data into smaller pieces called Segments. Ensures data arrives without errors using protocols like TCP and UDP.
(डाटा टुक्र्याउने र सुरक्षित पुगेको पक्का गर्ने)
Layer 3 Network Adds IP Addresses (Sender and Receiver). Decides the best physical path (Routing) for data to travel. Data here is called Packets.
(IP एड्रेस राख्ने र सबैभन्दा छोटो बाटो खोज्ने)
Layer 2 Data Link Adds Physical MAC Addresses. Checks for errors in the physical cable. Data here is called Frames.
(कम्प्युटरको फिक्स MAC एड्रेस राख्ने)
Layer 1 Physical Converts digital data into 0s and 1s (Bits) and sends it as electrical signals over wires or light over fiber cables.
(डाटालाई 0 र 1 मा बदलेर तारबाट पठाउने)

2. Network Devices (नेटवर्कका उपकरणहरू)

Hardware devices work at specific layers of the OSI model. Let's look at the most important ones:

A. Hub vs. Switch (Layer 1 vs. Layer 2)

Both are used to connect multiple computers in a LAN (Star Topology).

  • Hub (Dumb Device): Works at the Physical Layer. If PC 'A' sends a message to PC 'C', the Hub blindly broadcasts the message to EVERY computer connected to it. It wastes bandwidth and is not secure.
  • Switch (Smart Device): Works at the Data Link Layer. It remembers the MAC address of every connected computer. If PC 'A' sends a message to PC 'C', the Switch sends it only to PC 'C'. It is fast and secure.

B. Router (Layer 3)

A Router works at the Network Layer. While a Switch connects computers within the same network (LAN), a Router connects completely different networks together (like your home LAN to the ISP's network). It uses IP Addresses to route data packets across the internet.

C. Modem (Modulator-Demodulator)

Computers understand Digital signals (0s and 1s), but telephone/cable wires carry Analog signals (waves). A Modem converts Digital to Analog when sending data (Modulation), and Analog back to Digital when receiving data (Demodulation).
नेपालीमा: कम्प्युटरको डिजिटल डाटालाई टेलिफोनको तारबाट पठाउन एनालगमा बदल्ने मेसिन नै मोडेम हो।

🔍 Real-Life Case Study: Sending a Photo on WhatsApp

Spandana wants to send a photo of her notes to Buddha using WhatsApp. Let's trace it through the OSI Model!

  1. Application Layer: Spandana opens WhatsApp and selects the photo.
  2. Presentation Layer: The photo is compressed into a .JPEG format and encrypted so hackers can't see it.
  3. Session Layer: Spandana's phone establishes a continuous connection with Buddha's phone.
  4. Transport Layer: The 5MB photo is too big, so it is broken into thousands of small Segments.
  5. Network Layer: Buddha's IP Address is added to every segment so the Routers on the internet know where to send it.
  6. Data Link Layer: The physical MAC Address of her Wi-Fi router is added to the data.
  7. Physical Layer: The data is converted into radio waves (0s and 1s) and blasted from her phone to her Wi-Fi router! Buddha's phone receives these radio waves and does the exact reverse process (Layer 1 up to Layer 7) to display the image!

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 6 to Memorize:

  1. What is the OSI reference model? List its 7 layers in the correct order. (3 Marks)
  2. Explain the functions of the Network Layer and Transport Layer in the OSI Model. (5 Marks)
  3. Differentiate between a Hub and a Switch. Why is a Switch called an intelligent device? (3 Marks)
  4. What is a Router? At which OSI layer does it operate? (2 Marks)
  5. Describe the working mechanism of a Modem (Modulation and Demodulation). (3 Marks)
🚀 End of Part 6!
Incredible focus, Spandana and Buddha! The OSI model is tough, but you nailed it. Make sure you memorize the 7 layers in order (PDNTSPA). When you are ready to explore the Internet, IP Addresses, and Cyber Security, reply with:
"Start Part 7"

NEB 12 Computer Science: Ultimate Masterclass

🌍 Welcome to the Web, Spandana & Buddha!

You survived the OSI Model! Now, in Part 7, we are going to explore the modern Internet. How do computers find each other in a world of billions of devices? We will learn about IP Addresses, and more importantly, how to protect ourselves using Cyber Security and Nepal's Cyber Law. Let's dive in!

1. Internet vs. Intranet

Many students think the Internet and Intranet are the same thing. They are completely different in scale and privacy.

A. The Internet (विश्वव्यापी सञ्जाल)

The Internet is the global network of networks. It is public, open to everyone, and connects billions of devices worldwide using standard protocols like TCP/IP.
Example: Google, YouTube, Facebook.

B. The Intranet (निजी सञ्जाल)

An Intranet is a private network contained within a single organization (like a bank, school, or company). It uses the same technology as the Internet, but it is highly secure and only accessible to the employees of that organization.
नेपालीमा बुझ्नुस्: Intranet भनेको एउटा अफिस वा संस्थाभित्र मात्र चल्ने निजी इन्टरनेट हो। बाहिरका मान्छेले यसलाई चलाउन पाउँदैनन्।

C. What is Extranet?

If a company opens a small part of its highly secure Intranet to trusted partners or suppliers (with a special password), it is called an Extranet.

2. IP Addresses (इन्टरनेटको ठेगाना)

If you want to send a letter to a friend, you need their home address. On the internet, if your phone wants to download a video from YouTube, YouTube needs your phone's digital address. This is called an IP (Internet Protocol) Address.

A. IPv4 (Internet Protocol version 4)

This is the older, most common version. It is a 32-bit numeric address.
It looks like four numbers separated by dots (e.g., 192.168.1.1).
The Problem: IPv4 can only generate about 4.3 billion unique addresses. Since everyone now has a laptop, phone, and smart TV, we ran out of IPv4 addresses! (यसको ठेगाना सकिन लाग्यो).

B. IPv6 (Internet Protocol version 6)

To solve the shortage, IPv6 was created. It is a massive 128-bit alphanumeric address.
It uses both numbers and letters, separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
नेपालीमा: IPv6 ले यति धेरै नयाँ ठेगानाहरू दिन्छ कि संसारको हरेक बालुवाको कणलाई पनि एउटा छुट्टै IP ठेगाना दिन पुग्छ!

MAC Address vs. IP Address

  • MAC Address: The physical, permanent address burned into your device's hardware by the factory. (It never changes).
  • IP Address: The logical address assigned by your internet provider. (It changes when you move from your home Wi-Fi to a cafe's Wi-Fi).

3. Cyber Security & Cyber Law of Nepal

As we connect more devices to the internet, we invite more threats. Cyber Security is the practice of protecting systems, networks, and programs from digital attacks.

A. Malicious Software (Malware)

  • Virus: A program that damages your files but needs human action (like clicking a fake email link) to spread.
  • Worm: A dangerous program that can replicate and spread across a network by itself, without human help.
  • Trojan Horse: A virus disguised as a helpful software (like a free game). Once you install it, it opens a backdoor for hackers.

B. Firewall (भर्चुअल पर्खाल)

A Firewall is a security system (hardware or software) that monitors incoming and outgoing network traffic. It acts like a strict security guard at the gate. If traffic is unsafe, it blocks it.
नेपालीमा: Firewall भनेको तपाइँको कम्प्युटर र खतरनाक इन्टरनेट बिचको एउटा भित्ता (पर्खाल) हो जसले ह्याकर र भाइरसलाई भित्र आउन दिँदैन।

C. Cyber Law in Nepal (ETA 2063)

To control cybercrimes like hacking, data theft, and online harassment, Nepal introduced the Electronic Transaction Act (ETA) in 2063 BS (2006 AD).
This law gives legal validity to electronic records and Digital Signatures (a highly secure digital code attached to a document to verify its sender). It also specifies severe punishments and fines for cyber criminals.

🔍 Real-Life Case Study: Securing the FEEN Network

Spandana and Buddha set up a modern office for Focus Edge Education Network (FEEN).

They create an Intranet so their teachers can share confidential exam papers securely without putting them on the public internet. However, their students need to access study materials from home. So, they build a public website on the Internet.

One day, a hacker tries to send a Trojan Horse into the FEEN network to steal exam papers. Fortunately, Buddha had installed a powerful Firewall. The firewall scans the incoming data packets, detects the malicious code, and instantly blocks the hacker's IP Address. Spandana then uses the hacker's IP trace to file a police report under Nepal's Electronic Transaction Act (ETA 2063). The FEEN network remains safe!

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 7 to Memorize:

  1. Differentiate between the Internet and an Intranet. (3 Marks)
  2. What is an IP Address? Write any three differences between IPv4 and IPv6. (5 Marks - HIGH CHANCE)
  3. Define Firewall. Why is it essential for network security? (3 Marks)
  4. What is ETA 2063? Mention its primary objectives in the context of Nepal. (5 Marks)
  5. What is a Digital Signature? How does it help in secure electronic transactions? (2 Marks)
🚀 End of Part 7!
Outstanding work, Spandana and Buddha! You now understand how the internet operates and how to stay safe in the digital world. This officially marks the end of the Networking unit.

When you are ready to learn how to build dynamic websites and enter the world of Web Technology (PHP & JavaScript), reply with:
"Start Part 8"

NEB 12 Computer Science: Ultimate Masterclass

💻 Welcome to Web Technology, Spandana & Buddha!

In Grade 11, you learned HTML and CSS to design beautiful but "dead" websites. In Grade 12, we breathe life into them! Part 8 is all about Web Technology. We will learn how to make websites smart and dynamic using JavaScript (Client-Side) and PHP (Server-Side). This chapter is super practical and highly scoring!

1. Static vs. Dynamic Websites

Before writing code, we must understand what kind of website we are building.

A. Static Website (स्थिर वेबसाइट)

A static website is built using only HTML and CSS. The content is fixed. If you open it, and your friend opens it from another city, you both see the exact same thing.
नेपालीमा: यो पत्रिका (Newspaper) जस्तै हो। यसमा भएको कुरा सबैको लागि एउटै हुन्छ र आफैं परिवर्तन हुँदैन।

B. Dynamic Website (परिवर्तनशील वेबसाइट)

A dynamic website changes its content depending on the user, time, or database. Facebook is a dynamic website; when Spandana logs in, she sees her friends. When Buddha logs in, he sees his friends. It requires a Database and Scripting Languages (PHP, JS).
नेपालीमा: प्रयोगकर्ता अनुसार आफैं डाटा परिवर्तन हुने वेबसाइटलाई Dynamic Website भनिन्छ।

2. Client-Side Scripting (JavaScript)

In web development, the "Client" is YOUR computer's web browser (like Google Chrome). Client-side scripts are small programs that get downloaded and run entirely inside your browser.

JavaScript (JS)

JavaScript is the most popular client-side scripting language.
मुख्य काम: यसको मुख्य काम प्रयोगकर्ताले भरेको फारम (Form) जाँच्ने र वेबसाइटलाई आकर्षक (Interactive) बनाउने हो।

  • Form Validation: If you forget to type the '@' symbol in your email, JS immediately shows a red error before sending data to the server. This saves internet bandwidth.
  • Interactivity: Creating pop-up alerts, image sliders, and dark-mode toggles without reloading the webpage.
  • Security Risk: Since the code runs on the user's browser, anyone can right-click and see the JavaScript code. Do not put passwords here!
<script>
    alert("Welcome to FEEN, Spandana and Buddha!");
</script>

3. Server-Side Scripting (PHP)

The "Server" is the powerful computer far away that hosts the website. Server-side scripts run on that remote computer, do the heavy lifting, and only send the final HTML result back to the user.

PHP (Hypertext Preprocessor)

PHP is a widely-used server-side scripting language specially designed for web development.
मुख्य काम: यसको मुख्य काम डाटाबेस (Database) सँग कुरा गर्ने र गोप्य डाटालाई सुरक्षित राख्ने हो।

  • Database Connection: PHP can connect to MySQL databases to save new user accounts, fetch NEB results, or check passwords.
  • Security: The user NEVER sees the PHP code. They only see the HTML output generated by PHP. This makes it highly secure for handling payments and logins.
  • Dynamic Content: It generates dynamic web pages on the fly based on what the user asks for.
<?php
    $name = "Buddha";
    echo "Hello, " . $name . "! Your PHP code is working.";
?>

🔍 Real-Life Case Study: The FEEN Login Page

Spandana and Buddha are building a secure login page for NEB students. Let's see how JS and PHP work together as a team!

  1. The Setup: Buddha creates a login form using HTML.
  2. Client-Side (JavaScript): Spandana types her password but forgets to type her username and clicks "Login". JavaScript immediately stops her! It pops up an alert: "Please enter your username!" This happens instantly on her browser without talking to the server.
  3. Server-Side (PHP): She types both username and password and clicks Login. Now, the data is sent to the web server. PHP takes over! PHP checks the MySQL Database to see if her password is correct. If yes, PHP generates a personalized welcome dashboard and sends it back to her browser.

Conclusion: JS handles the front door (Validation), PHP handles the vault (Database & Security).

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 8 to Memorize:

  1. Differentiate between Static and Dynamic Websites. (3 Marks)
  2. What is the difference between Client-Side Scripting and Server-Side Scripting? (5 Marks - VERY IMPORTANT)
  3. Why is JavaScript used for Form Validation instead of PHP? (2 Marks)
  4. Define PHP. Mention any two major advantages of using Server-Side scripting. (3 Marks)
🚀 End of Part 8!
Brilliant work, Spandana and Buddha! You now understand the core mechanics of how modern websites are built using JS and PHP.

When you are ready to start writing actual JavaScript Programs (Variables, Loops, and Functions) for your exam, reply with:
"Start Part 9"

NEB 12 Computer Science: Ultimate Masterclass

⚡ Let's Write Some Code, Spandana & Buddha!

In Part 8, we learned that JavaScript handles the "Front Door" of a website. Today, in Part 9, we are going to write actual JavaScript programs! We will learn how to store data (Variables), make decisions (If-Else), repeat tasks (Loops), and create reusable recipes (Functions). These coding concepts are the foundation of ALL programming languages.

1. Variables in JavaScript (डाटा राख्ने भाँडो)

A variable is simply a container for storing data values. Imagine you have a box, you write "Age" on the outside, and you put the number "18" inside it.

How to create variables in JS?

In modern JavaScript, we use let or const to create variables.

  • let: Used for data that can change later. (पछि परिवर्तन हुन सक्ने डाटा)
  • const: Used for data that is fixed and CANNOT be changed. (कहिले पनि परिवर्तन नहुने डाटा)
// Storing text (String)
let studentName = "Spandana";

// Storing a number (Number)
let marks = 85;

// Using const for a fixed value
const pi_value = 3.1415;

2. Control Structures (निर्णय र लुप)

A computer program needs to make decisions. "If the student gets 80, print A. Else, print B." This is called conditional logic.

A. If-Else Statement (सर्त राख्ने)

It checks a condition. If the condition is TRUE, it runs the first block of code. If FALSE, it runs the "else" block.

let age = 18;

if (age >= 18) {
    alert("You can vote!");
} else {
    alert("You are too young to vote.");
}

B. The "For" Loop (काम दोहोर्याउने)

What if you want to print "Hello" 5 times? You don't write it 5 times. You use a Loop!
नेपालीमा: एउटै काम पटक-पटक दोहोर्याउन Loop को प्रयोग गरिन्छ।

// It starts at 1, stops at 5, and increases by 1 (i++)
for (let i = 1; i <= 5; i++) {
    document.write("Hello FEEN! <br>");
}

3. Functions (कामको प्याकेज)

A Function is a block of code designed to perform a particular task. You write it once, and you can "call" it as many times as you want.

Why use functions? Reusability! If you need to calculate GST tax on 50 different products, you don't write the formula 50 times. You create a calculateTax() function.
सजिलो भाषामा: फङ्सन भनेको कुनै निश्चित काम गर्न बनाइएको कोडको टुक्रा (Recipe) हो। यसलाई जति पटक पनि प्रयोग गर्न सकिन्छ।

// 1. Creating the Function
function addNumbers(num1, num2) {
    let sum = num1 + num2;
    alert("The total is: " + sum);
}

// 2. Calling the Function
addNumbers(10, 20); // Output: The total is 30

🔍 Real-Life Case Study: Buddha's Grading System

Buddha is building a small web app for his teachers. The teacher types a student's marks, and the website automatically tells them if the student Passed or Failed.

How Buddha builds it:
He creates a Function named checkResult(). Inside this function, he creates a Variable called marks to store the typed number. Then, he uses an If-Else statement:
If marks are greater than or equal to 35, display "Passed!". Else, display "Failed."

Now, every time the teacher clicks the "Check" button on the webpage, the browser calls Buddha's function and does the math instantly. This makes the static HTML page highly dynamic and interactive!

📝 Board Exam Preparation (Target: A+)

VVI Questions from Part 9 to Memorize:

  1. What is a variable in JavaScript? What is the difference between let and const? (3 Marks)
  2. Write a simple JavaScript program using a for loop to print numbers from 1 to 10. (4 Marks)
  3. What is a Function in JavaScript? Explain its advantages (Reusability). (3 Marks)
  4. Write a JavaScript code using an if-else statement to check whether a person's age makes them eligible to vote (Age >= 18). (5 Marks - HIGH CHANCE)
🚀 End of Part 9!
Awesome coding, Spandana and Buddha! You have officially learned the basic logic of programming.

When you are ready to combine this knowledge with Server-Side processing and learn PHP Forms and Database Connectivity, reply with:
"Start Part 10"

NEB 12 Computer Science: Ultimate Masterclass

🚀 Triple Threat Unlocked, Spandana & Buddha!

You asked for Parts 10, 11, and 12, and here they are! We are going to wrap up Web Technology with PHP Database Connections, and then leap straight into the most crucial programming chapter of Grade 12: Advanced C Programming (Structures, Unions, and File Handling). Grab your notebooks, this is going to be massive!

Part 10: PHP Form Handling & Database Connectivity

In Part 9, we learned JavaScript. Now, let's learn how to take data from a user (like a Registration Form) and save it permanently into a MySQL Database using PHP.

1. Form Handling: GET vs. POST (डाटा पठाउने तरिका)

When you submit an HTML form, the data travels to the server using either the GET or POST method.

  • GET Method: Sends data by attaching it to the URL (web address).
    Example: www.feen.com/login.php?user=buddha&pass=123
    कमजोरी: यो सुरक्षित हुँदैन किनकि पासवर्ड URL मा छर्लङ्ग देखिन्छ। It is only used for searching (like Google Search).
  • POST Method: Sends data hidden inside the HTTP body. The URL remains clean.
    फाइदा: यो एकदमै सुरक्षित हुन्छ। Login, Registration, र Payment गर्दा सधैं POST प्रयोग गर्नुपर्छ।

2. Connecting PHP to MySQL Database (डाटाबेस जोड्ने)

To talk to a database, PHP needs 4 magic keys: Server Name, Username, Password, and Database Name.

<?php
// Step 1: Create connection variables
$server = "localhost";
$user = "root";
$pass = ""; // Blank in XAMPP
$dbname = "feen_db";

// Step 2: Establish the connection using mysqli_connect
$conn = mysqli_connect($server, $user, $pass, $dbname);

// Step 3: Check if it worked
if (!$conn) {
    die("Connection Failed! " . mysqli_connect_error());
} else {
    echo "Database Connected Successfully!";
}
?>

🔍 Real-Life Case Study: Spandana's Admission Portal

Spandana builds an Admission Form for FEEN. A new student types their Name and clicks 'Submit'.

She uses the POST method in her HTML form. When the data reaches the server, her PHP code catches it using a special variable called $_POST['name']. Then, her PHP script uses mysqli_connect to open the door to the MySQL database, and uses the SQL INSERT INTO command to save the student's name permanently into the digital filing cabinet. The admission is successful!

📝 Exam Prep (Part 10)

  • Differentiate between GET and POST methods in PHP. (3 Marks)
  • Write a PHP script to establish a connection with a MySQL Database. (5 Marks - VERY IMPORTANT)

Part 11: Advanced C - Structure and Union

In Grade 11, you learned Arrays in C. An array is a box that holds many items, but they MUST be of the same type (e.g., 10 integers). But what if we want to store a student's Roll Number (Integer), Name (Text), and Percentage (Decimal) in a single box? Arrays will fail! We need a Structure.

1. Structure (संरचना)

A Structure is a user-defined data type in C that groups together different types of variables under a single name.
नेपालीमा: फरक-फरक प्रकारका डाटा (जस्तै Number, Text, Decimal) लाई एउटै नामभित्र बाँधेर राख्ने तरिका नै Structure हो।

// Creating a Structure
struct Student {
    int roll;
    char name[50];
    float marks;
};

void main() {
    struct Student s1; // s1 is now a box that holds roll, name, and marks!
    s1.roll = 5;
    s1.marks = 85.5;
}

2. Union (युनियन)

A Union is exactly like a Structure, with one massive difference: Memory Allocation.

  • In a Structure, every variable gets its own separate memory room. (Roll gets 2 bytes + Name gets 50 bytes + Marks gets 4 bytes = 56 bytes total).
  • In a Union, all variables SHARE the exact same memory room. The size of the union is only equal to its largest variable (50 bytes).
    कमजोरी: एउटै कोठा सेयर गर्ने भएकोले युनियनमा एक पटकमा एउटा डाटा मात्र सुरक्षित राख्न सकिन्छ। एउटा राख्दा अर्को आफैं मेटिन्छ।

🔍 Real-Life Case Study: Buddha Managing Exam Records

Buddha is writing a C program to manage the final NEB records. If he uses normal variables, he needs 300 variables for 100 students (roll1, name1, mark1, roll2...). This is crazy!

Instead, he creates a struct Student. Then, he creates an Array of Structures: struct Student NEB[100];. Now, he has 100 neat boxes, and each box perfectly holds a roll number, a name, and a mark. His code shrinks from 500 lines to just 20 lines!

📝 Exam Prep (Part 11)

  • What is a Structure? How is it different from an Array? (3 Marks)
  • Differentiate between Structure and Union regarding memory allocation. (5 Marks - HIGH CHANCE)
  • Write a C program using a structure to store the name, roll, and marks of a student and display it. (5 Marks)

Part 12: Advanced C - File Handling

Everything you wrote in C so far was stored in the computer's RAM. What happens when you close the black output screen? POOF! The data disappears forever. To save data permanently so you can read it tomorrow, we use File Handling to save it directly to the Hard Drive.

1. The File Pointer (फाइल पोइन्टर)

To talk to a file on your hard disk, C requires a special pointer called a FILE Pointer.
Syntax: FILE *fp;

2. File Modes (फाइल खोल्ने तरिकाहरू)

Before you do anything, you must open the file using fopen() and tell the computer why you are opening it.

  • "w" (Write Mode): Opens a file to write data into it. Danger: If the file already has data, "w" will completely erase the old data and overwrite it! (पुरानो डाटा मेटेर नयाँ लेख्छ).
  • "a" (Append Mode): Opens a file to add data. It saves the old data and writes the new data at the very end. (पुरानो डाटा नमेटी थप्दै जान्छ).
  • "r" (Read Mode): Opens a file only to read it. You cannot write anything.

3. Essential File Functions

  • fopen(): To open a file.
  • fprintf(): Just like printf, but instead of printing to the screen, it prints text INTO the file!
  • fscanf(): To read text FROM the file.
  • fclose(): Always close the file when you are done to save it safely.
#include <stdio.h>
void main() {
    FILE *fp;
    // Open file in Write mode
    fp = fopen("student.txt", "w");

    // Write text into the file
    fprintf(fp, "Spandana and Buddha are learning C!");

    // Close and save
    fclose(fp);
}

🔍 Real-Life Case Study: Saving FEEN Receipts

Spandana writes a Billing Software in C for FEEN classes. She uses standard printf. When she prints a receipt, it shows on the screen, but when she turns off her laptop, the receipt record is lost forever.

Buddha tells her to use File Handling. She updates her code using fopen("bills.txt", "a"). She uses "a" (Append) so that today's receipts don't erase yesterday's receipts. Now, every time she generates a bill, fprintf secretly writes it into the bills.txt file on her hard drive. The data is now safe forever!

📝 Exam Prep (Part 12)

  • What is File Handling in C? Why is it necessary? (3 Marks)
  • Differentiate between 'Write (w)' and 'Append (a)' mode in file handling. (2 Marks - VERY IMPORTANT)
  • Write a C program to open a file named "nepal.txt" and write "I love my country" into it. (5 Marks)
🚀 End of Parts 10, 11, & 12!
Take a massive bow, Spandana and Buddha! You just conquered the heaviest programming concepts in the Grade 12 syllabus. Take a good rest and review these codes.

When you are ready to learn about modern software building (Software Engineering, SDLC, Prototyping), reply with:
"Start Part 13"

NEB 12 Computer Science: Ultimate Masterclass

🚀 The Grand Expansion, Spandana & Buddha!

You have conquered programming and databases. But how are massive apps like eSewa or Facebook actually built? They aren't just typed up overnight by one person. Today, in Parts 13, 14, 15, and 16, we move from writing small codes to managing massive IT projects, exploring Artificial Intelligence, and diving into E-commerce. Let's go!

Part 13: System Development Life Cycle (SDLC)

Before building a house, you need an architect, a blueprint, and a testing plan. Similarly, to build massive software, IT professionals use the SDLC.

1. What is SDLC? (प्रणाली विकास चक्र)

SDLC is a structured, step-by-step process used by software industries to design, develop, and test high-quality software. It ensures the software is built on time and within budget.

2. The 6 Phases of SDLC (सम्झनै पर्ने ६ चरणहरू)

  • 1. Investigation (अध्ययन): What is the problem? Is building this software technically and financially possible? (This is called a Feasibility Study).
  • 2. Analysis (विश्लेषण): Gathering requirements. What does the user actually want the software to do?
  • 3. Design (ढाँचा निर्माण): Creating the blueprint, database models (ER diagrams), and user interface designs. No coding happens here!
  • 4. Coding / Development (प्रोग्रामिङ): The programmers finally sit down and write the actual C, PHP, or Java code.
  • 5. Testing (परीक्षण): Finding and fixing bugs (errors) to make sure the software doesn't crash.
  • 6. Implementation & Maintenance (लागू र मर्मत): Installing the software on the client's computer and fixing any future issues.

3. The System Analyst (प्रणाली विश्लेषक)

The System Analyst is the main hero of SDLC. They are the bridge between the client (who doesn't know coding) and the programmer (who only knows coding).
नेपालीमा: System Analyst ले ग्राहकको आवश्यकता बुझेर प्रोग्रामरलाई कस्तो सफ्टवेयर बनाउने भनेर निर्देशन दिन्छ।

🔍 Real-Life Case Study: Buddha's Hospital Software

A hospital asks Buddha to build a patient management system. Buddha doesn't start typing code instantly!
First, as a System Analyst, he visits the hospital (Investigation). He asks doctors what features they need (Analysis). He draws the screen designs on paper (Design). Then, he tells Spandana (the programmer) to write the code (Development). Finally, they run fake patient data to check for errors (Testing) before handing it over.

📝 Exam Prep (Part 13)

  • What is SDLC? Briefly explain its various phases. (5 or 8 Marks - HIGH CHANCE)
  • Who is a System Analyst? List any three roles/duties of a System Analyst. (3 Marks)
  • What is a Feasibility Study? Why is it done before developing a system? (3 Marks)

Part 14: Object-Oriented Programming (OOP)

C programming is a "Procedural" language (step 1, step 2, step 3). But modern languages like C++, Java, and Python use OOP. OOP models the real world. Instead of focusing purely on logic, it focuses on "Objects."

The 6 Pillars of OOP (अब्जेक्ट ओरिएन्टेड प्रोग्रामिङका आधारहरू)

1. Class (क्लास - ढाँचा)

A class is a blueprint or template. It doesn't physically exist.
Example: The concept of a "Car" is a Class. It has properties (color, tires) and actions (drive, brake).

2. Object (अब्जेक्ट - वास्तविक वस्तु)

An object is a real-world instance of a Class. It takes up physical memory.
Example: Buddha's red Ferrari is an Object of the "Car" class.

3. Encapsulation (इनक्याप्सुलेसन - क्याप्सुलमा राख्ने)

Wrapping data (variables) and functions into a single unit (a Class) to protect it from outside interference.
नेपालीमा: जसरी औषधिको धूलोलाई क्याप्सुलभित्र प्याक गरेर सुरक्षित राखिन्छ, त्यसरी नै डाटालाई सुरक्षित राख्नु नै Encapsulation हो।

4. Inheritance (इन्हेरिटेन्स - वंशानुगत गुण)

When a new class acquires the properties of an old class. It promotes code reusability.
Example: A "Smartphone" class inherits all basic features from the "Mobile Phone" class, but adds internet features.

5. Polymorphism (पोलिमर्फिजम - बहुरूपता)

The ability of one function or object to take many forms.
Example: A person can be a student in a classroom, a customer in a mall, and a son at home. One person, different behaviors.

6. Abstraction (एब्स्ट्रयाक्सन - भित्री कुरा लुकाउने)

Hiding complex background details and showing only the essential features.
Example: You know how to press the accelerator to make a car go fast, but you don't need to know how the engine burns fuel inside. That is abstraction!

📝 Exam Prep (Part 14)

  • Differentiate between Procedural Programming (like C) and Object-Oriented Programming (like C++). (5 Marks)
  • Define Class and Object with suitable real-world examples. (3 Marks)
  • Explain the concepts of Encapsulation and Polymorphism. (5 Marks - VERY IMPORTANT)

Part 15: AI & Contemporary Technologies

Technology changes rapidly. In this part, we look at the modern tech trends dominating the world right now.

1. Artificial Intelligence (AI - कृत्रिम बौद्धिकता)

AI is the simulation of human intelligence in machines. It allows computers to learn from experience, recognize speech, and make decisions without human help.
Examples: ChatGPT, Self-driving Tesla cars, Apple's Siri.

2. Internet of Things (IoT - इन्टरनेट अफ थिङ्स)

IoT refers to a network of everyday physical objects (things) embedded with sensors and software that connect and exchange data over the internet.
नेपालीमा: कम्प्युटर र मोबाइल मात्र नभई घरको टिभी, फ्रिज, बत्ती, र ढोकालाई इन्टरनेटसँग जोडेर मोबाइलबाटै कन्ट्रोल गर्नुलाई IoT भनिन्छ।
Example: Spandana forgets to turn off her AC at home, so she turns it off using her phone from college!

3. Cloud Computing (क्लाउड कम्प्युटिङ)

Instead of saving your files or running software on your own computer's hard drive, you use the internet to store and access data on giant servers owned by companies like Google or Amazon.
Examples: Google Drive, iCloud, Netflix.

4. Big Data (बिग डाटा)

Extremely large and complex datasets that traditional data processing software (like Excel) cannot manage. Companies analyze Big Data to find patterns in human behavior (e.g., YouTube recommending videos based on millions of your past clicks).

📝 Exam Prep (Part 15)

  • What is Artificial Intelligence? Mention its any two applications in daily life. (3 Marks)
  • Define IoT (Internet of Things). Give one practical example of a Smart Home. (3 Marks)
  • What is Cloud Computing? List its two advantages (e.g., Cost-saving, anywhere access). (3 Marks)

Part 16: E-Commerce, E-Governance & ICT

How has technology changed business and government? It brought everything to our fingertips.

1. E-Commerce (विद्युतीय व्यापार)

E-commerce is the buying and selling of goods or services using the internet, and the transfer of money to execute these transactions.

  • B2C (Business to Consumer): A company selling directly to you. (Example: Buying shoes from Daraz).
  • B2B (Business to Business): A company selling bulk materials to another company. (Example: Alibaba wholesale).
  • C2C (Consumer to Consumer): Normal people selling used items to other normal people. (Example: Hamrobazaar.com).

2. E-Governance (विद्युतीय शासन)

The application of Information and Communication Technology (ICT) by the government to provide public services quickly, transparently, and efficiently.
नेपालीमा: सरकारी कार्यालयमा लाइन नबसी इन्टरनेटको माध्यमबाट सरकारी काम (जस्तै: लाइसेन्स फर्म भर्ने, कर तिर्ने) गर्नु नै E-Governance हो।
Examples in Nepal: Nagarik App, Online Passport Application, IRD Tax Portal.

3. Mobile Commerce (M-Commerce) & E-Payment

M-Commerce is a specific part of E-commerce where trading happens strictly through mobile devices.
To support this, we use Online Payment Gateways (Digital Wallets) to transfer money securely.
Examples in Nepal: eSewa, Khalti, IME Pay, Fonepay.

🔍 Real-Life Case Study: FEEN Goes Digital!

Spandana and Buddha register FEEN classes. First, they use the government's E-Governance portal to register their company online and pay their taxes. Then, they build an E-Commerce (B2C) website to sell their NEB video courses directly to students. To make it easy for students to buy, they integrate the eSewa API (E-Payment) so students can pay instantly from their phones (M-Commerce)!

📝 Exam Prep (Part 16)

  • What is E-commerce? Explain B2B, B2C, and C2C with one example of each. (5 Marks - HIGH CHANCE)
  • What is E-Governance? How has the Nagarik App helped Nepalese citizens? (3 Marks)
  • Define Online Payment Gateway. List any two popular payment gateways in Nepal. (2 Marks)
🚀 End of Parts 13, 14, 15, & 16!
You are absolute legends, Spandana and Buddha! We have covered almost all the theoretical chapters of Grade 12 Computer Science.

When you are completely ready to enter the final stretch with Part 17, 18, 19, and 20 (Multimedia, Cyber Ethics, and Revision Strategy), reply with:
"Start Part 17"

NEB 12 Computer Science: Ultimate Masterclass

🏆 The Grand Finale, Spandana & Buddha!

This is it! You have reached the final four parts of the syllabus. In Parts 17 and 18, we will explore the creative world of Multimedia and the strict rules of Cyber Ethics. Finally, in Parts 19 and 20, we are going to break down the exact NEB Board Exam pattern, time management, and the ultimate strategy to score an A+. Let's finish this journey!

Part 17: Multimedia Technology

We see it every day on Instagram, TikTok, and YouTube. But what exactly is Multimedia?

1. What is Multimedia? (मल्टिमिडिया भनेको के हो?)

The word is a combination of Multi (many) and Media (forms of communication). Multimedia is the integration of Text, Audio, Video, Graphics, and Animation into a single digital presentation.
नेपालीमा: अक्षर, आवाज, भिडियो, र चित्रलाई एउटै डिजिटल माध्यममा मिलाएर प्रस्तुत गर्नु नै मल्टिमिडिया हो।

2. The 5 Core Components of Multimedia

  • Text: The basic written words.
  • Graphics/Images: Static pictures (JPEG, PNG). Includes Raster Graphics (made of pixels, lose quality when zoomed) and Vector Graphics (made of math formulas, never lose quality).
  • Audio: Sound files (MP3, WAV).
  • Video: Moving pictures with sound (MP4, AVI).
  • Animation: Giving motion to drawings or computer-generated objects (2D or 3D).

3. Virtual Reality (VR) vs. Augmented Reality (AR)

These two modern technologies are highly examinable:

  • Virtual Reality (VR / भर्चुअल रियालिटी): Completely replaces your real world with a 100% fake computer-generated 3D world. You wear a VR Headset (like Oculus Rift) and feel like you are inside a video game.
  • Augmented Reality (AR / अगमेन्टेड रियालिटी): Keeps you in the real world but adds (augments) digital layers on top of it.
    Example: Playing Pokémon GO! You look through your phone camera and see a digital Pikachu sitting on your real-life study table!

📝 Exam Prep (Part 17)

  • Define Multimedia and briefly explain its five components. (5 Marks)
  • Differentiate between Virtual Reality (VR) and Augmented Reality (AR) with real-life examples. (3 Marks)
  • What is the difference between Vector graphics and Raster (Bitmap) graphics? (2 Marks)

Part 18: Information Security & Cyber Ethics

Now that we have powerful internet and multimedia, we must behave responsibly. The internet has laws and moral rules just like the physical world.

1. Cyber Ethics (साइबर नैतिकता)

Cyber Ethics are the moral principles and rules of behavior that dictate how a person should use the internet. It is about doing the "right" thing online.
नेपालीमा: इन्टरनेट चलाउँदा अरुलाई दुःख नदिने, झुटो नबोल्ने र मर्यादित व्यवहार गर्ने नैतिक नियम नै साइबर नैतिकता हो।

Core Rules: Do not bully others online (Cyberbullying), do not spread fake news, and respect other people's privacy.

2. Intellectual Property (IP) Rights

If you build a house, the physical house is your property. If you write a song or create software, that is the creation of your mind. This is called Intellectual Property.

  • Copyright (प्रतिलिपि अधिकार): The legal right that gives the creator of original work exclusive rights to use and distribute it. Nobody can copy it without permission.
  • Software Piracy (सफ्टवेयर चोरी): The illegal copying, distributing, or selling of copyrighted software (e.g., using a cracked version of Microsoft Office or a paid video game).
  • Plagiarism (साहित्यिक चोरी): Copying someone else's essay, project, or code from the internet and presenting it to your teacher as your own original work. (अरुको काम चोरेर आफ्नै हो भनेर दाबी गर्नु).

3. Digital Footprint (डिजिटल छाप)

Everything you do online—the photos you like, the comments you post, the websites you visit—leaves a permanent digital trace. Even if you delete a comment, the server has a record of it. This trace is your Digital Footprint. You must be careful because future employers and universities will check it!

📝 Exam Prep (Part 18)

  • What is Cyber Ethics? List any three basic rules of cyber ethics. (3 Marks)
  • Differentiate between Software Piracy and Plagiarism. (3 Marks)
  • Define Digital Footprint. Why is it important to manage your digital footprint? (2 Marks)

Part 19: NEB Board Exam Pattern & Analytical Strategy

To score an A+, you don't just need knowledge; you need Strategy. You must understand exactly how NEB designs the Computer Science question paper.

The 50 Marks Breakdown (New Curriculum)

In Grade 12, Computer Science theory is evaluated out of 50 Marks. You have exactly 2 Hours (120 minutes) to complete the paper.

  • Section A (MCQs): 9 Questions × 1 Mark = 9 Marks
    Strategy: These are conceptual. Spend maximum 1 minute per question. Do not leave any blank.
  • Section B (Short Answer Questions): 5 Questions × 5 Marks = 25 Marks
    Strategy: You will get "OR" options in a couple of questions. Write point-wise! If a question asks for differences, always draw a T-table. (Spend about 12-14 minutes per question).
  • Section C (Long Answer Questions): 2 Questions × 8 Marks = 16 Marks
    Strategy: These usually come from Database (Normalization/SQL) and C-Programming/System Development. Always include diagrams, flowcharts, or syntax code to get full 8 marks! (Spend about 20 minutes per question).

How to Write Answers Like a Topper?

  • Use Subheadings: Don't write long boring paragraphs. Break them down.
  • Always Add Examples: If asked "What is an IP address?", give the definition AND write an example: (e.g., 192.168.1.1).
  • For Programming Questions: If asked about a C Structure or a PHP loop, write the definition, write the general syntax, and then write a short 3-line code example. The examiner will immediately give you full marks!

Part 20: Exam Day Strategy & The Practical 50 Marks

Theory is only half the battle. The other 50 Marks are in your hands during your internal and final practical exams!

1. Securing the Practical 50 Marks

The practical marks are usually divided into:

  • Lab Report / File (10 Marks): Ensure your file is neat, indexed, and contains the required C programs, PHP forms, and SQL queries.
  • Project Work (10-15 Marks): You must submit a working project. Tip for Spandana & Buddha: Build a simple "Student Management System" using PHP and MySQL. It looks highly professional and guarantees top marks.
  • Viva Voce (10 Marks): The external examiner will ask you rapid-fire questions. They will look at your project and ask, "What does this line of code do?" Be confident, and if you don't know, honestly say you don't know rather than guessing blindly.
  • Computer Lab Test (15 Marks): You will be asked to write and run a C program or SQL query live on the computer.

2. Time Management in the Examination Hall (The 120-Minute Rule)

Many students know all the answers but fail to finish the paper. Here is your ultimate time division:

Section Total Marks Time to Spend
Section A (MCQs) 9 10 Minutes
Section B (Short) 25 60 Minutes (12 mins per Q)
Section C (Long) 16 40 Minutes (20 mins per Q)
Review Paper - 10 Minutes
🎓 Congratulations, Spandana Basnet and Buddha Chiring Gurung! 🎓

You have successfully completed all 20 Parts of the Ultimate NEB Grade 12 Computer Science Masterclass! We have covered everything from the basics of Database Management to advanced C-Programming, Web Technologies, Networking, AI, and Exam Strategies.

Remember, Computer Science is not just about memorizing theories; it is about building logic and solving problems. Review these notes, practice your codes, and step into that examination hall with absolute confidence. The Focus Edge Education Network (FEEN) team wishes you a brilliant A+ and an incredibly bright future in IT!

NEB 12 Computer Science: C Programming Master Practice

💻 Code Like a Pro, Spandana & Buddha!

To master C Programming, theory is not enough. You must understand how to write and trace the code. Here are 10 Highly Examinable C Programming Questions. Read the code first, and then read the detailed explanation to understand exactly how the logic works!

Question 1: Basic Input/Output and Arithmetic

Q: Write a C program to calculate the area of a circle given its radius.
#include <stdio.h>

int main() {
    float radius, area;
    const float PI = 3.14159;

    printf("Enter the radius of the circle: ");
    scanf("%f", &radius);

    area = PI * radius * radius;

    printf("The area of the circle is: %.2f\n", area);

    return 0;
}

Detailed Explanation:

  • #include <stdio.h>: Includes the standard input/output library required to use printf and scanf.
  • float radius, area;: Declares two decimal variables.
  • const float PI: We define PI as a constant so its value cannot be accidentally changed during the program.
  • scanf("%f", &radius);: Reads a float (%f) from the user and stores it at the memory address of the radius (&radius).
  • %.2f: Inside the output printf, this formats the result to display exactly 2 digits after the decimal point.

Question 2: Conditional Statements (If-Else)

Q: Write a C program to check whether a given integer is even or odd.
#include <stdio.h>

int main() {
    int num;

    printf("Enter an integer: ");
    scanf("%d", &num);

    if (num % 2 == 0) {
        printf("%d is an Even number.\n", num);
    } else {
        printf("%d is an Odd number.\n", num);
    }

    return 0;
}

Detailed Explanation:

  • num % 2 == 0: The % (modulo) operator divides the first number by the second and returns the remainder. If a number is perfectly divisible by 2, the remainder is 0.
  • if...else block: The program evaluates the condition. If the remainder is exactly equal to 0, it executes the block inside the if statement (Even). If the remainder is anything else (e.g., 1), it skips to the else block (Odd).

Question 3: Iteration (Loops)

Q: Write a C program to print the Fibonacci series up to 'n' terms.
#include <stdio.h>

int main() {
    int n, t1 = 0, t2 = 1, nextTerm;

    printf("Enter the number of terms: ");
    scanf("%d", &n);

    printf("Fibonacci Series: ");

    for (int i = 1; i <= n; ++i) {
        printf("%d, ", t1);
        nextTerm = t1 + t2;
        t1 = t2;
        t2 = nextTerm;
    }

    return 0;
}

Detailed Explanation:

  • The Logic: The Fibonacci series is a sequence where each number is the sum of the two preceding ones (0, 1, 1, 2, 3, 5...).
  • Variables: t1 holds the first term (0), t2 holds the second term (1), and nextTerm holds their sum.
  • for loop: The loop runs n times. First, it prints the current t1. Then, it calculates nextTerm = t1 + t2. Finally, it shifts the numbers forward: t1 takes the value of t2, and t2 takes the value of nextTerm.

Question 4: User-Defined Functions

Q: Write a C program to find the factorial of a number using a user-defined function.
#include <stdio.h>

// Function declaration
long long calculateFactorial(int n);

int main() {
    int num;
    printf("Enter a positive integer: ");
    scanf("%d", &num);

    if (num < 0) {
        printf("Error! Factorial of a negative number doesn't exist.\n");
    } else {
        printf("Factorial of %d = %lld\n", num, calculateFactorial(num));
    }
    return 0;
}

// Function definition
long long calculateFactorial(int n) {
    long long fact = 1;
    for (int i = 1; i <= n; ++i) {
        fact *= i;
    }
    return fact;
}

Detailed Explanation:

  • long long calculateFactorial(int n);: This is a function prototype. It tells the compiler to expect a function that takes an integer and returns a very large integer (long long), which is necessary because factorials grow huge quickly (e.g., 10! = 3,628,800).
  • Inside the Function: We set fact = 1. A loop multiplies fact by every number from 1 to n. (e.g., 1 * 2 * 3 * 4...). Finally, return fact; sends the answer back to the main program.

Question 5: Arrays

Q: Write a C program to find the largest element in an array of integers.
#include <stdio.h>

int main() {
    int n;
    printf("Enter the number of elements: ");
    scanf("%d", &n);

    int arr[n];
    printf("Enter %d numbers:\n", n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &arr[i]);
    }

    int largest = arr[0];

    for (int i = 1; i < n; ++i) {
        if (arr[i] > largest) {
            largest = arr[i];
        }
    }

    printf("The largest element is: %d\n", largest);
    return 0;
}

Detailed Explanation:

  • Populating the Array: A for loop combined with scanf asks the user to input numbers, filling up the array from index 0 to n-1.
  • The Finding Logic: We assume the first element arr[0] is the largest and save it in the largest variable. We then loop through the rest of the array. If we find any number bigger than our current largest, we update the largest variable.

Question 6: Strings (Character Arrays)

Q: Write a C program to reverse a string without using built-in string functions.
#include <stdio.h>

int main() {
    char str[100];
    int length = 0;

    printf("Enter a string: ");
    scanf("%s", str);

    // Find length manually
    while (str[length] != '\0') {
        length++;
    }

    printf("Reversed string: ");
    for (int i = length - 1; i >= 0; i--) {
        printf("%c", str[i]);
    }
    printf("\n");

    return 0;
}

Detailed Explanation:

  • Strings in C: A string is just an array of characters ending with a special hidden null character '\0'.
  • Finding Length: The while loop counts characters until it hits that null terminator. If you type "Apple", length becomes 5.
  • Reversing: The for loop starts at length - 1 (the last actual letter, because arrays start at index 0) and counts backward down to 0, printing one character (%c) at a time.

Question 7: Pointers (Call by Reference)

Q: Write a C program to swap the values of two variables using pointers.
#include <stdio.h>

void swap(int *a, int *b);

int main() {
    int num1 = 10, num2 = 20;

    printf("Before swapping: num1 = %d, num2 = %d\n", num1, num2);
    swap(&num1, &num2);
    printf("After swapping: num1 = %d, num2 = %d\n", num1, num2);

    return 0;
}

void swap(int *a, int *b) {
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

Detailed Explanation:

  • Passing Addresses: When calling swap(&num1, &num2), we don't pass the numbers 10 and 20. We pass their memory addresses using the & operator.
  • Dereferencing: Inside the swap function, int *a receives the address. The * operator (dereference) allows us to access and alter the actual value stored in that physical memory address.
  • The Swap: We temporarily store the value of *a into temp. Then we copy *b into *a, and finally put temp into *b. Because we manipulated the real memory locations, the original variables in main() are permanently swapped.

Question 8: Structures

Q: Write a C program to store the roll number, name, and marks of a student using a structure and display it.
#include <stdio.h>

// Define the structure
struct Student {
    int roll;
    char name[50];
    float marks;
};

int main() {
    struct Student s1;

    printf("Enter Roll Number: ");
    scanf("%d", &s1.roll);

    printf("Enter Name: ");
    scanf("%s", s1.name); // No '&' needed for string arrays

    printf("Enter Marks: ");
    scanf("%f", &s1.marks);

    printf("\n--- Student Details ---\n");
    printf("Roll Number: %d\n", s1.roll);
    printf("Name: %s\n", s1.name);
    printf("Marks: %.2f\n", s1.marks);

    return 0;
}

Detailed Explanation:

  • struct Student { ... };: This creates a custom data type named Student that groups an integer, a string, and a float together into one package.
  • struct Student s1;: Creates an actual box (variable) named s1 that contains all those fields.
  • The Dot Operator (.): To access or modify individual pieces of data inside the structure, we use the dot operator. For example, s1.roll targets the roll number specifically for student s1.

Question 9: Recursion

Q: Write a C program to calculate the sum of the first 'n' natural numbers using recursion.
#include <stdio.h>

int sum(int n);

int main() {
    int num;
    printf("Enter a positive integer: ");
    scanf("%d", &num);

    printf("Sum = %d\n", sum(num));
    return 0;
}

int sum(int n) {
    if (n != 0) {
        return n + sum(n - 1); // Recursive call
    } else {
        return n; // Base case
    }
}

Detailed Explanation:

  • Recursion: A function that calls itself to solve a smaller version of the problem.
  • The Base Case: if (n == 0) return n;. This stops the function from running forever. If it hits 0, it stops calling itself.
  • The Recursive Step: return n + sum(n - 1);. If you input 3, it returns 3 + sum(2). Then sum(2) returns 2 + sum(1). When it finally hits 0, it adds them all backward: 1 + 2 + 3 = 6.

Question 10: File Handling

Q: Write a C program to write a sentence to a file, close it, and then open the file to read and display its contents.
#include <stdio.h>
#include <stdlib.h>

int main() {
    FILE *fptr;
    char sentence[100];
    char ch;

    // 1. Write to file
    fptr = fopen("test.txt", "w");
    if (fptr == NULL) {
        printf("Error opening file!\n");
        exit(1);
    }

    printf("Enter a sentence to write: ");
    fgets(sentence, sizeof(sentence), stdin);
    fprintf(fptr, "%s", sentence);
    fclose(fptr);
    printf("Data saved to file.\n\n");

    // 2. Read from file
    fptr = fopen("test.txt", "r");
    printf("Reading from file:\n");
    while ((ch = fgetc(fptr)) != EOF) {
        printf("%c", ch);
    }
    fclose(fptr);

    return 0;
}

Detailed Explanation:

  • FILE *fptr;: Creates a file pointer, which acts as a bridge between your program and the hard drive.
  • Writing Phase ("w" mode): fopen("test.txt", "w") opens a file for writing. If it doesn't exist, C creates it. fprintf() works like printf, but it writes the text permanently into the file instead of the screen.
  • Reading Phase ("r" mode): We reopen the file strictly for reading. The fgetc(fptr) grabs a single character from the file. The while loop continues to print characters until it hits EOF (End Of File), a special hidden marker indicating there is no more text to read.

NEB 12 Computer Science: The Final Challenge

🛠️ Time to Test Your Logic, Spandana & Buddha!

You've seen the top 10 questions. Now, here are 3 Master-Level Challenge Questions. But this time, we are doing it differently. You must use the "Black Box" Dry Run Method. Read the problem, read the suggestion, trace the logic on a piece of paper, and then click the "Run Black Box" command below to verify your logic!

Challenge 1: The Palindrome Test

Q: Write a C program to check whether a given integer is a Palindrome or not.

💡 Pro Suggestion & Strategy:

A palindrome number reads the same forwards and backwards (e.g., 121, 4554).
How to solve: Do not just look at the code! Grab a pen. Imagine the user enters 121.
1. Store the original number in a temporary variable (so you don't lose it).
2. Use a while loop to extract the last digit using modulo: rem = num % 10.
3. Build the reversed number: rev = rev * 10 + rem.
4. Chop off the last digit: num = num / 10.
5. Finally, check if your rev matches the original temporary variable!

#include <stdio.h>

int main() {
    int n, reversed = 0, remainder, original;
    printf("Enter an integer: ");
    scanf("%d", &n);
    original = n;

    while (n != 0) {
        remainder = n % 10;
        reversed = reversed * 10 + remainder;
        n /= 10;
    }

    if (original == reversed)
        printf("%d is a palindrome.", original);
    else
        printf("%d is not a palindrome.", original);

    return 0;
}

Challenge 2: Prime Number Inspector

Q: Write a C program using a user-defined function to check if a number is Prime.

💡 Pro Suggestion & Strategy:

A prime number is only divisible by 1 and itself (e.g., 2, 3, 5, 7, 11).
How to solve: Create a function checkPrime(int n). Inside the function, set a flag variable `isPrime = 1`. Use a for loop starting from i = 2 up to n / 2. If `n % i == 0` at any point, it means the number is divisible by something else! Immediately change the flag to `0` and break the loop.

#include <stdio.h>

int checkPrime(int n);

int main() {
    int n, flag;
    printf("Enter a positive integer: ");
    scanf("%d", &n);

    flag = checkPrime(n);

    if (flag == 1)
        printf("%d is a prime number.", n);
    else
        printf("%d is not a prime number.", n);
    return 0;
}

int checkPrime(int n) {
    if (n == 0 || n == 1) return 0;
    for (int i = 2; i <= n / 2; ++i) {
        if (n % i == 0) {
            return 0; // Not prime
        }
    }
    return 1; // Prime
}

Challenge 3: The Vowel Counter

Q: Write a C program to count the total number of vowels in a string entered by the user.

💡 Pro Suggestion & Strategy:

Vowels are A, E, I, O, U.
How to solve: Declare a string array char str[100]. Use gets() or fgets() to read a sentence with spaces. Loop through the array using while (str[i] != '\0'). Inside the loop, use an if condition with the logical OR operator || to check if the current character matches any lower-case or upper-case vowel. If yes, increment a `count` variable.

#include <stdio.h>

int main() {
    char line[150];
    int vowels = 0, i = 0;

    printf("Enter a line of string: ");
    fgets(line, sizeof(line), stdin);

    while (line[i] != '\0') {
        if (line[i] == 'a' || line[i] == 'e' || line[i] == 'i' ||
            line[i] == 'o' || line[i] == 'u' || line[i] == 'A' ||
            line[i] == 'E' || line[i] == 'I' || line[i] == 'O' ||
            line[i] == 'U') {
            ++vowels;
        }
        ++i;
    }

    printf("Vowels: %d", vowels);
    return 0;
}
C:\FEEN_Compiler\BlackBox> _

// Instructions: Have you mentally dry-run the codes above?
// Click a command below to compile and execute the logic in the Black Box terminal.

NEB 12 Computer Science: Mega Quiz

Welcome, Spandana & Buddha!

This is your ultimate test. You have 35 Questions covering the entire Grade 12 syllabus.

⚠️ RULES: You have exactly 35 Seconds per question. Once you click an option, it locks permanently. If the timer hits zero, the question locks automatically!

Question 1 / 35
⏱️ 35s
Loading question...

🎉 Quiz Completed!

Your Final Score is:

0 / 35

Please take a screenshot of this page and send it to WhatsApp: 9851402725

Comments

Popular posts from this blog

Teacher Index – Teaching Jobs & Terms and Conditions in Nepal

100 Ways to Earn Money from Nepal (2025) — Work From Home Ideas for Students & Professionals | Work From Home in Nepal: Best Online Jobs & Payment Methods (Payoneer, eSewa, Khalti)

Work From Home Nepal 2025 — 100 Proven Online Jobs, Sites & Payment Methods (Payoneer/eSewa/Khalti)