-->

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;
    }

    Data types and variables

     Data type:-

    In C programming, a data type is a classification that specifies the type of data that a variable can hold, the operations that can be performed on the data, and the amount of memory allocated for the data. The data type determines the range of values that a variable can store and the operations that can be performed on the variable.

    Data types' example:-


         int,float,long int, double etc. are some examples of data types in C language.

     Types of 'Data type' in c language:-

    Data types in the C language can be classified into the following categories:

    1. Basic/Primitive Data Types:

       - Integer Types: char, int, short, long

       - Floating-Point Types: float, double, long double
       - Void Type: void
       - Boolean Type: _Bool


    2. Derived Data Types:
       - Arrays: A collection of elements of the same type.
       - Pointers: Variables that store memory addresses.
       - Structures: User-defined data types that can contain multiple members of different types.
       - Unions: Similar to structures but only one member can be accessed at a time.
       - Enumerations: User-defined data types consisting of named integer constants.

    3. User-Defined Data Types:
       - Typedef Names: Created using the typedef keyword to create new names for existing data types.

    The basic/primitive data types are the fundamental building blocks of the C language and are used to store individual values. Derived data types are derived from the basic/primitive types and allow for more complex data structures and operations. User-defined data types allow programmers to create custom data types based on their specific needs.

    Each data type has its own characteristics, such as size, range of values, and operations that can be performed on them. Choosing the appropriate data type is essential for efficient memory usage and proper manipulation of data in C programs.

    structure of a c program

    The basic parts of c program: 

    The structure of a typical C program consists of several components that are arranged in a specific order. Here is the general structure of a C program:


    1. Preprocessor Directives: 

    The program may begin with preprocessor directives, indicated by the '#' symbol. These directives are used to include header files or define constants that are needed for the program.


    2. Global Declarations: 

    Following the preprocessor directives, global variable and function declarations can be included. Global variables are accessible throughout the program, while function declarations provide information about functions that will be defined later in the program.


    3. Main Function: 

    Every C program must have a main function, which serves as the entry point for program execution. The main function is where the program's instructions are written.


    4. Variable Declarations: 

    Inside the main function, variables can be declared. These variables are used to store data that will be manipulated or used in the program.


    5. Statements and Expressions: 

    The main body of the program consists of statements and expressions. Statements perform actions or control the flow of execution, while expressions compute values or perform calculations.


    6. Function Definitions: 

    In addition to the main function, other functions may be defined within the program. These functions can be called from the main function or other functions to perform specific tasks.


    7. Return Statement: 

    At the end of the main function or any other function, a return statement can be used to specify the value that the function should return to the calling function. The return statement is optional in the main function but required in other functions with non-void return types.


    Sample of C program:


    Here is a simplified example of a C program structure:

    //my first program in C

    #include <stdio.h>


    // Global variable declaration

    int globalVariable;


    // Function declaration

    void someFunction();


    // Main function

    int main() {

        // Variable declarations

        int localVariable;


        // Statements and expressions

        printf("Hello, World!\n");


        // Call another function

        someFunction();


        // Return statement

        return 0;

    }


    // Function definition

    void someFunction() {

        // Function body

        // ...

    }


    It's important to note that this structure provides a basic framework for organizing a C program, but the specific implementation and complexity can vary depending on the requirements of the program.

    how to set up C environment

     How to  set up C coding environment

    To set up the C environment, you need to follow these steps:

    1. Choose a Text Editor or Integrated Development Environment (IDE): You can use a simple text editor like Notepad++ or choose a more feature-rich IDE like Code::Blocks, Eclipse, or Visual Studio. IDEs often provide additional tools and features for coding, debugging, and project management.

    2. Install a C Compiler: A C compiler is required to compile and run C programs. Popular C compilers include GCC (GNU Compiler Collection), Clang, and Microsoft Visual C++. Install the compiler that is compatible with your operating system.

    3. Set Up the Compiler Path: After installing the C compiler, you need to set up the compiler path so that the system can find it. This involves adding the compiler's directory to the system's PATH environment variable. Instructions for setting the PATH variable vary depending on the operating system you are using.

    4. Write and Save a C Program: Open your chosen text editor or IDE and write your C program. Save the program with a ".c" extension. For example, "myprogram.c".

    Here we are taking devC++.



    5. Compile the C Program: Open a command prompt or terminal and navigate to the directory where your C program is saved. Use the command provided by your installed C compiler to compile the program. For GCC, the command is usually "gcc" followed by the name of your C file. For example: `gcc myprogram.c -o myprogram` (This will produce an executable file named "myprogram").

    6. Run the Compiled Program: After successful compilation, you can run the compiled program by executing the generated executable file. In the command prompt or terminal, enter the name of the executable file (e.g., `myprogram`), and hit Enter. The program will then run and display the output, if any.

    That's it! You have set up the C environment and can start writing, compiling, and running C programs on your system. Remember to save your C programs with a ".c" extension and compile them before executing.

    Features of C

     Important features of C language are listed below.


    1. Simplicity: 

    C has a relatively simple and minimalistic syntax, making it easy to learn and understand. It has a small set of keywords and a straightforward structure, which contributes to its readability and maintainability.


    2. Efficiency:

     C is known for its efficiency in terms of execution speed and memory usage. It allows direct memory manipulation and provides low-level control over hardware resources. C programs can be optimized for performance, making it suitable for developing applications with strict resource constraints or performance requirements.


    3. Portability: 

    C code can be compiled and executed on different platforms and operating systems with minimal modifications. The language is designed to be machine-independent, with a focus on abstracting away hardware-specific details. This portability is facilitated by the use of compilers that generate machine code specific to the target platform.


    4. Modularity: 

    C supports modular programming through the use of functions and libraries. Programs can be divided into smaller, reusable modules, making them easier to develop, understand, and maintain. C libraries provide a wide range of pre-written functions that can be included in programs, reducing the need to reinvent common functionalities.


    5. Low-level Features: 

    C allows direct manipulation of memory addresses and provides features like pointers, which enable efficient memory management and data structures. This low-level control is particularly useful in system programming, embedded systems, and device drivers.


    6. Flexibility:

     C supports both procedural and structured programming paradigms. It allows programmers to organize code into functions and control structures like loops and conditionals. Additionally, C can be used for object-oriented programming (OOP) with the help of additional libraries like C++ or Objective-C.


    7. Extensibility: 

    C allows programmers to extend the language through the use of libraries and user-defined functions. This enables the creation of custom functionalities and the integration of C code with other programming languages.


    8. Standardized: 

    The C language has a standardized syntax and semantics defined by ANSI (American National Standards Institute) and ISO (International Organization for Standardization). These standards ensure compatibility and portability of C code across different platforms and compilers.


    9. Wide Usage and Support: 

    C has a large and active community of developers, making it easy to find resources, libraries, and support. There are numerous textbooks, online tutorials, forums, and open-source projects available to help programmers learn and work with C.


    These features contribute to the popularity and versatility of the C programming language, making it a powerful choice for a wide range of applications, including system programming, embedded systems, game development, scientific computing, and more.

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

    Previous                                                                                                Next

    History of C language

    Who developed C language?

    Dennis Ritchi

     The history of the C programming language dates back to the early 1970s. C was developed by Dennis Ritchie at Bell Labs (formerly AT&T Bell Laboratories) as a successor to the B programming language. Ritchie initially created C to aid in the development of the Unix operating system, which was also being developed at Bell Labs.

    BCPL  language:-

    The roots of C can be traced back to an earlier programming language called BCPL (Basic Combined Programming Language), which was developed by Martin Richards in the mid-1960s. BCPL influenced the development of B, which in turn laid the foundation for C. Ritchie and Ken Thompson, another Bell Labs researcher, had previously worked on the development of the Multics operating system using BCPL and saw the need for a more efficient and portable language.


    In 1972, Ritchie made significant enhancements to the B language, adding data types, operators, and other features, and renamed it C. The name "C" was chosen because it followed the alphabetical progression from B, and also because many of its features were derived from an earlier language called CPL (Combined Programming Language).

    Development of  unix Operating system using C language:-

    C gained popularity within Bell Labs and was used extensively for the development of the Unix operating system. The ability to write efficient and portable code in C played a significant role in the widespread adoption of Unix. As Unix began to gain popularity in the late 1970s and early 1980s, the use of C spread beyond Bell Labs, and programmers from other organizations started embracing the language.


    In 1978, the first edition of "The C Programming Language" book, written by Brian Kernighan and Dennis Ritchie (commonly known as K&R C), was published. This book became the authoritative reference for the C language and helped solidify its popularity. It provided clear explanations and examples of the language's features and coding techniques.


    The influence of C continued to grow in the 1980s. In 1983, the American National Standards Institute (ANSI) established a committee to standardize the C language, resulting in the ANSI C standard in 1989. This standard, often referred to as C89 or C90, helped ensure the portability of C code across different platforms.


    In 1990, an updated version of the C standard, known as C99, was published. C99 introduced several new features and improvements to the language, including support for inline functions, variable-length arrays, and new data types.


    In recent years, the C language has remained widely used and influential. Its simplicity, efficiency, and portability continue to make it a preferred choice for system programming, embedded systems, and various other applications. The C programming language has also served as the foundation for other languages, such as C++, Objective-C, and C#.

    Introduction to C

     C is a widely-used and influential programming language known for its efficiency and versatility. It was developed in the early 1970s by Dennis Ritchie at Bell Labs as a successor to the B programming language. C was initially designed to facilitate system programming and to provide a higher-level alternative to assembly language.


    Key features of the C language include its low-level nature, which allows direct memory manipulation and efficient hardware access, as well as its simple syntax and structured programming constructs. C provides a balance between high-level abstraction and low-level control, making it suitable for a wide range of applications, including operating systems, embedded systems, device drivers, game development, and scientific computing.


    C has a small set of keywords and operators, making it relatively easy to learn. It supports essential programming constructs such as variables, data types, control flow statements (if-else, loops), functions, arrays, and pointers. These features provide the foundation for building complex programs and data structures.


    One of the strengths of C is its portability. C programs can be compiled and run on various platforms, including Windows, macOS, Linux, and even embedded systems like microcontrollers. This portability is achieved by separating the language itself from the underlying hardware, making C a "machine-independent" language.


    Another important aspect of C is its close relationship with the operating system. C allows direct access to memory and hardware resources, making it suitable for system-level programming. It provides features like pointers and structures, which enable efficient memory management and manipulation.


    C has influenced the development of numerous other programming languages, including C++, Java, C#, and Objective-C. Many popular software applications and operating systems, such as the Unix operating system and the Linux kernel, have been written in C.


    Overall, C is a powerful and flexible programming language that offers a fine-grained control over the hardware, making it a preferred choice for systems programming and performance-critical applications. Its simplicity, efficiency, and wide range of applications have contributed to its enduring popularity among programmers.