-->

Tuesday, May 20, 2025

c program to print maximum and minimum value | Array examples

 C program to find the greatest and smallest value among 5 numbers entered by user

//array program to input 5 numbers and to print maximum and minimum value

#include<stdio.h>
#define size 5
int main()
{
int a[size];//array declaration with size 5
int i,max,min;
for(i=0;i<=4;i++)
{
printf(" enter value for location=%d\n",i+1);
scanf("%d",&a[i]);//inputs
}
max=a[0];//assigning first value to max and min
min=a[0];
for(i=0;i<=4;i++)
{
if(max<a[i])//comparing and changing the old value
{
max=a[i];
}
if(min>a[i])//comparing and assigning new value
{
min=a[i];
}
}
printf("the max value=%d and minimum value is %d",max,min);//printing
return 0;
}

Output:-



C program to copy one array element to another | Array examples

Array programs in C

C program to copy one array elements to another 

/* program to copy one array element to another
*/

#include<stdio.h>
int main()
{
int a[5];
int b[5];
int i;
for(i=0;i<=4;i++)
{
printf("enter elment for %d location",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<=4;i++)
{
b[i]=a[i];
}
printf("the copied elements are:\n");
for(i=0;i<=4;i++)
{
printf(" %d ",b[i]);
}
return 0;
}


Output:-

c program to copy elements to another array



Monday, May 19, 2025

C Program to Input elements and to find average value using array-1D array concept

 

C program to input elements and to find average 


//array input and printing average value

#include<stdio.h>

int main()

{

int a[5];//array declaration

int i,sum=0;//variable declaration

float average;//float to store average

for(i=0;i<=4;i++)

{

printf(" enter value for location=%d\n",i+1);

scanf("%d",&a[i]);//input for given array

sum+=a[i]; //finding sum

}

average=(float)sum/5; //type casting and storing average in variable

printf("the average value is=%f",average);//printng result

return 0;

}

Output:-

C program to find average of five elements using array



second method:

//array input and printing average value. Here, we will use define for size.

#include<stdio.h>
#define size 5
int main()
{
int a[size];//array declaration with size as an index value. It takes the value from define
int i,sum=0;//variable declaration
float average;//float to store average
for(i=0;i<=4;i++)
{
printf(" enter value for location=%d\n",i+1);
scanf("%d",&a[i]);//input for given array
sum+=a[i]; //finding sum
}
average=(float)sum/5; //type casting and storing average in variable
printf("the average value is=%f",average);//printng result
return 0;
}





Sunday, May 18, 2025

C Program – 1D Array Input and Output with Simple Examples

array input in C program 


// 1Dimensional (1D) array input


#include<stdio.h>
int main()
{
int a[5];//array declaration of size 5
int i;
for(i=0;i<=4;i++)//loop
{
printf(" enter value for location=%d\n",i+1);//message display
scanf("%d",&a[i]);//input
}
for(i=0;i<=4;i++)
{
printf("%d\t",a[i]);//printing the values
}
return 0;
}


Output:-




C Program – Array Declaration and Initialization | With Examples

 Array initialization in C


// 1D array initialization


#include<stdio.h>
int main()
{
int a[5]={12,23,45,78,55};
//array declaration and initialization
int i;//variable declaration
for(i=0;i<=4;i++)//loop
{
printf("%d\t",a[i]);//printing values
}
return 0;
}


Output:-

1D Array initialization in C































Sunday, May 4, 2025

NEB Computer Science 2082 | computer science Questions & Solved Answers

 



NEB-GRADE XII
2082 (2025) Computer Science

Sub.Code: 4281'D'

(For regular and partial students whose first two digits of registration

number starts from 78, 79, 80 and 81)

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

Time: 2 hrs.

Full Marks: 50

Multiple choice questions.
Group 'A' [9x1=9]   4281'D'

1. Which of the following is the purpose of using primary key in database? 

A) To uniquely identify a record

B) To store duplicate record

C) To backup data

D) To enhance database size

Ans:A) To uniquely identify a record

2. A company needs to modify an existing table by adding a new column for employee email addresses. For this, which SQL command should be used?

 A) CREATE

B) ALTER 

C) SELECT 

D) UPDATE


Ans:-B) ALTER 

3. Which protocol is used for secure communication over a computer network?

A) HTTP

B) FTP

C) HTTPS

D) Telnet


Ans:C) HTTPS


4. Which control structure in JS (Java Script) is used to execute a block of code repeatedly based on a given condition?

A) For loop

B) if-else

C) switch case 

D) function


Ans:-A) For loop

5. Select the invalid variable name in PHP.

A) $name

B) $_name

C) $1name

D) $name123

Ans:C) $1name

6. The statement int number (int a); is a ...

A) function call

B) function definition

C) function declaration

D) function execution


Ans:-C) function declaration

7. In which of the following programming, the emphasis is given on data rather than on procedures ?

A) Procedural programming

B) Structural programming

C) Object-oriented programming

D) Declarative programming


Ans:C) Object-oriented programming


8. Which type of feasibility study evaluates whether a system can be developed with the available technology?.

A) Operational feasibility

B) Social feasibility

C) Technical feasibility

D) Economical feasibility


Ans:-C) Technical feasibility

9. Which of the following is NOT a type of cloud computing service ?

A) Infrastructure as a Service (IaaS)

B) Platform as a Service (PaaS)

C) Software as a Service (SaaS) 

D) Hardware as a Service (HaaS)


Ans:-D) Hardware as a Service (HaaS)


Group 'B'[5x5=25]


Short answer questions

10. Write any three differences between DDL and DML. Give examples of each.                        [3+2]
            OR
What is normalization? Explain 2NF and 3NF.                                                                              [2+3]
11. Write JavaScript code to input any three numbers and find the smallest number among them.
            OR                                                                                                                                           [5]
Write a PHP script to connect to a MySQL database.                                                                        [5]
12. Write short notes on class and inheritance in oops.                                                                     [5] 
13. What is Requirement Gathering? Explain different Requirement Gathering
methods.                                                                                                                                             [1+4]
14. What is AI? Explain application areas of AI in education.                                                         [5]


Group 'C'
Long answer questions[2x8=16]

15. What is transmission medium? Explain its major types with advantages and disadvantages.[2+6] 
16. Write a C program that reads the account_number, name and address of ten customers from users and displays the account_number, name and address of these customers using Array and structure.
 OR                                                                                                                                                    [8]
What are the components of a function of C? Describe the Call - by - value and Call - by - reference and passing the function parameters.                                                                                                 [4+4]

 

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


NEB-GRADE XII
2082 (2025) Computer Science solutions

Sub.Code: 4281'D'

(For regular and partial students whose first two digits of registration

number starts from 78, 79, 80 and 81)

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

Time: 2 hrs.

Full Marks: 50

Multiple choice questions.
Group 'A' [9x1=9]   4281'D'

1. Which of the following is the purpose of using primary key in database? 

A) To uniquely identify a record

B) To store duplicate record

C) To backup data

D) To enhance database size

Ans:A) To uniquely identify a record

2. A company needs to modify an existing table by adding a new column for employee email addresses. For this, which SQL command should be used?

 A) CREATE

B) ALTER 

C) SELECT 

D) UPDATE


Ans:-B) ALTER 

3. Which protocol is used for secure communication over a computer network?

A) HTTP

B) FTP

C) HTTPS

D) Telnet


Ans:C) HTTPS


4. Which control structure in JS (Java Script) is used to execute a block of code repeatedly based on a given condition?

A) For loop

B) if-else

C) switch case 

D) function


Ans:-A) For loop

5. Select the invalid variable name in PHP.

A) Sname

B) $_name

C) $1name

D) $name123

Ans:C) $1name

6. The statement int number (int a); is a ...

A) function call

C) function declaration

B) function definition

D) function execution


Ans:-C) function declaration

7. In which of the following programming, the emphasis is given on data rather than on procedures ?

A) Procedural programming

C) Object-oriented programming

B) Structural programming

D) Declarative programming


Ans:C) Object-oriented programming


8. Which type of feasibility study evaluates whether a system can be developed with the available technology?.

A) Operational feasibility

B) Social feasibility

C) Technical feasibility

D) Economical feasibility


Ans:-C) Technical feasibility

9. Which of the following is NOT a type of cloud computing service ?

A) Infrastructure as a Service (IaaS)

B) Platform as a Service (PaaS)

C) Software as a Service (SaaS) 

D) Hardware as a Service (HaaS)


Ans:-D) Hardware as a Service (HaaS)


Group 'B'[5x5=25]


Short answer questions

10. Write any three differences between DDL and DML. Give examples of each.                        [3+2]

Ans:-

 The differences between DDL and DML are given below.

DDL

DML

DDL Stand For Data Definition Language

DML Stand for Data Manipulation Language

It is used to create the database schema

It is used to populate and manipulate database

CREATE, ALTER, DROP, TRUNCATE AND COMMENT and RENAME, etc

SELECT, INSERT, UPDATE, DELETE, MERGE, CALL, etc

SQL Statement can't be rollback

SQL Statement can be rollback

DDL Command affect the entire database or the table

Command affect one or more records in a table

Examples:

DDL:

CREATE TABLE Students (id INT, name VARCHAR(50));

DML:

INSERT INTO Students (id, name) VALUES (1, 'Sita');


            OR

What is normalization? Explain 2NF and 3NF.                                                                              [2+3]

Ans:-

Normalization:-

Normalization is the process of organizing data in a database to reduce data redundancy (repetition) and improve data integrity. It involves dividing large tables into smaller related tables and defining relationships between them. This makes the database more efficient and easier to maintain and removes all anomalies that may happen while inserting,updating,and deleting records.

2NF:-

Second Normal Form (2NF):

A table is in Second Normal Form (2NF) if:

  • It is already in First Normal Form (1NF), and

  • All non-key attributes are fully functionally dependent on the entire primary key (not just part of it, in case of a composite key).
    This removes partial dependency and helps avoid data duplication. 

Third Normal Form (3NF):

A table is in Third Normal Form (3NF) if:

  • It is in 2NF, and

  • There is no transitive dependency, meaning non-key attributes do not depend on other non-key attributes.
    This helps ensure that each non-key field is only dependent on the primary key.

11. Write JavaScript code to input any three numbers and find the smallest number among them.

            OR                                                                                                                                           [5]

Ans:-
<!DOCTYPE html>
<html>
<head>
  <title>Find Smallest Number</title>
</head>
<body>
<script>
  let num1 = parseFloat(prompt("Enter first number:"));
  let num2 = parseFloat(prompt("Enter second number:"));
  let num3 = parseFloat(prompt("Enter third number:"));
  let smallest = Math.min(num1, num2, num3);
  alert("The smallest number is: " + smallest);
</script>
</body>
</html>

OR

Write a PHP script to connect to a MySQL database.                                                                        [5]

Ans:-

 <?php

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

if (!$connection) 

{

    echo"Connection failed: " . mysqli_connect_error();

}

else

{

echo "Connected successfully";

}

mysqli_close($connection);

?>

12. Write short notes on class and inheritance in oops.                                                                     [5] 

Ans:

Class:
In Object-Oriented Programming (OOP), a class is a blueprint or template for creating objects. It defines properties (called attributes or data members) and behaviors (called methods or functions) that the objects created from the class will have.

 For example, a Car class might have attributes like color and model, and methods like start() and stop(). Classes help in organizing code, promoting reuse, and improving readability.

example:-

 class Car 

{

private:

    string color="green":

    void color_car() 

{

        cout << " it is " << color<<endl;

    }

};

Inheritance:
Inheritance is an important feature of OOP that allows one class (called the child or subclass) to acquire the properties and behaviors of another class (called the parent or superclass). This helps in reusing existing code and creating a hierarchical relationship between classes. There are multiple types of inheritance like single inheritance, multiple imheritance,multilevel inheritance etc.

For example, a Dog class can inherit from an Animal class and automatically get its methods like eat() and sleep(). Inheritance promotes code reuse and reduces redundancy. 

class Animal {         

public:

    void eat() {

        cout << "Eating..." << endl;

    }

};

class Dog : public Animal {   

public:

    void bark() {

        cout << "Barking..." << endl;

    }

};

13. What is Requirement Gathering? Explain different Requirement Gathering.

Ans:-

Requirement gathering:

Requirement Gathering in the Software Development Life Cycle (SDLC) is the process of collecting detailed information about what a software system should do from stakeholders such as clients, users, and business analysts. It is the first and one of the most critical phases of SDLC, where the project's goals, features, functions, and constraints are clearly understood and documented. This ensures that the development team builds the right product that meets the user's needs and expectations.

Different methods of gathering:-

During the Analysis Phase of the Software Development Life Cycle (SDLC), various requirement gathering techniques help in accurately understanding user needs and system requirements. 

Here's how they contribute:

  1. Interviews

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

  2. Surveys and Questionnaires

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

  3. Use Cases and User Stories

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

  4. Workshops

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

  5. Prototyping

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

                                                                                                                                           [1+4]

14. What is AI? Explain application areas of AI in education.                                                         [5]

Ans:-

Artificial Intelligence:

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

Its applications in the education are given below.

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

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

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

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

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


Group 'C'
Long answer questions[2x8=16]

15. What is transmission medium? Explain its major types with advantages and disadvantages.[2+6] 

Ans:-

Transmission Medium:
A transmission medium is a physical path or channel through which data travels from the sender to the receiver in a communication system. It is the medium that carries the signals or data between different devices in a network. Transmission media can be wired (guided) or wireless (unguided).

We have mainly following types.

Under guided media, here are the pros and cons of  each media.

  1. Twisted Pair Cable (Wired):-A type of wired transmission medium where two insulated copper wires are twisted together to reduce electromagnetic interference.

    • Advantages:

      • Low cost compared to other mediums.

      • Easy to install and maintain.

    • Disadvantages:

      • Limited bandwidth and prone to interference.

      • Signal degradation over long distances.

  2. Coaxial Cable (Wired):- A type of wired transmission medium that consists of a central conductor, insulating layer, metallic shield, and outer insulation, offering better resistance to interference.

    • Advantages:

      • Higher bandwidth and better performance than twisted pair cables.

      • More resistant to interference and can cover longer distances without significant signal loss.

    • Disadvantages:

      • More expensive than twisted pair cables.

      • Bulky and harder to install compared to twisted pair cables.

  3. Fiber Optic Cable (Wired):A high-speed, wired transmission medium that uses light to transmit data through glass or plastic fibers, offering high bandwidth and low signal loss.

    • Advantages:

      • Very high bandwidth and extremely fast data transfer.

      • Immune to electromagnetic interference (EMI) and radio frequency interference (RFI).

    • Disadvantages:

      • Expensive to install and maintain.

      • Installation requires specialized equipment and expertise.

Under unguided media, here are the pros and cons of  each media.



  1. Radio Waves (Wireless):-A wireless transmission medium that uses electromagnetic waves to transmit data over short to long distances, often used in mobile communication and Wi-Fi.

    • Advantages:

      • Can transmit data over long distances without the need for wires.

      • Widely used for mobile communication, Wi-Fi, and Bluetooth.

    • Disadvantages:

      • Prone to interference from weather, buildings, and other electronic devices.

      • Limited bandwidth compared to wired media.


  2. Microwave (Wireless):-A wireless transmission medium that uses high-frequency radio waves to transmit data over long distances in a line-of-sight manner.

    • Advantages:

      • High data rates for point-to-point communication.

      • Suitable for long-distance communication with line-of-sight.

    • Disadvantages:

      • Requires line-of-sight between transmitter and receiver, limiting deployment.

      • Weather conditions (like rain) can affect signal quality.

  3. Satellite Communication (Wireless):-A wireless transmission medium that uses satellites in space to transmit and receive data across large geographical areas, such as for global communications and broadcasting.

    • Advantages:

      • Can cover very large geographical areas, even remote locations.

      • Used for global communication, TV broadcasting, and internet services.

    • Disadvantages:

      • High latency (signal delay) due to long-distance travel.

      • Expensive to set up and maintain.

[Write any two media.]


16. Write a C program that reads the account_number, name and address of ten customers from users and displays the account_number, name and address of these customers using Array and structure.
                                                                                                                                                  [8]

Ans:-


#include <stdio.h>
struct Customer
{
        int account_number;
        char name[50];
        char address[100];
};
int main()
{
        struct Customer customers[10];
        int i;
        for ( i = 0; i < 10; i++)
        {
            printf("Enter details for customer %d:\n", i + 1);
            printf("Account Number: ");
            scanf("%d", &customers[i].account_number);
            printf("Name: ");
            gets(customers[i].name);
            printf("Address: ");
            gets(customers[i].address);
            printf("\n");
        }
printf("\n Customer Details are:\n");
for (i = 0; i < 10; i++)
{
        printf("\nCustomer %d:\n", i + 1);
        printf("Account Number: %d\n", customers[i].account_number);
        printf("Name: %s", customers[i].name);
        printf("Address: %s", customers[i].address);
}
return 0;
}

OR

What are the components of a function of C? Describe the Call - by - value and Call - by - reference and passing the function parameters.                                                                                                 [4+4]

Ans:-

First part:-

Function:-

In C programming, a function is a block of code that performs a specific task. It allows us to break down a program into smaller, manageable parts. Functions are used to reuse code, make programs more organized, and improve readability.

In C programming, a function typically consists of the following components:

1. Function Name/prototype:

 Also called function prototype, it is an identifier used to declare the function. It should be descriptive and follow the naming conventions with or without parameters.

            example:  void sum();
            Here, sum() is a function prototype with return type void.

2. Return Type

Specifies the type of value that the function will return to the caller. It can be any valid C data type, such as int, float, char, or void (for no return value).
        Example:   
         return sum;

3.Parameters/Arguments (Optional):

 These are the values passed to the function when called. Parameters define the input for the function and are listed in the parentheses after the function name.
            int sum(float a ,float b);
            Here, we have two parameters a and b.

4. Body/function definition

This contains the actual code that defines what the function does. It is enclosed within {} and may include local variables, loops, conditional statements, etc. It is called function definition part where we define many things.
        Example:
            void sum(float a,float b)
            {
                float s;
                s=a+b; 
            }

5. Function call: 

AS we write all the statements inside the functions, as per demand, we call them from particular function or main function to get its output. It is called function calling. To call the function, we simply put function name, with or without parameters.


Example:
int main()
{ sum(3,4);//calling of function
}
 void sum(float a,float b)// it is definition part
   {
                float s;
                s=a+b; 
   }

Second part:

Call by Value:-

In Call by Value, a copy of the actual argument is passed to the function. Changes made to the parameter inside the function do not affect the actual argument.

Example:

#include <stdio.h>
void add(int a, int b) ;//prototype
int main() 
{

int x = 5, y = 10;
add(x, y); 
printf("x = %d, y = %d (unchanged)\n", x, y);
return 0;
}
void add(int a, int b) 
{
a = a + b; 
printf("Sum inside function: %d\n", a);
}

Call by Reference:-

In Call by Reference, the address of the actual argument is passed to the function, so any changes made to the parameter will affect the actual argument.

Example:

#include <stdio.h>
void add(int *a, int *b) ;//prototype
int main()
{
int x = 5, y = 10;
add(&x,&y);
printf("x = %d, y = %d (changed)\n", x, y);
return 0;
}
void add(int *a, int *b)
{
*a = *a + *b;
printf("Sum inside function: %d\n", *a);
}

HISSAN computer science || Grade 12 Computer Science 2081 – Full Questions & Solutions

 

 

HISSAN CENTRAL EXAMINATION 2081 (2025)

Grade: XII Time: 2 hrs

F.M.: 50

COMPUTER SCIENCE (4281 M1)

Candidates are required to give their answers in their own words as far as practicable.

Multiple Choice Questions.

GROUP A
Writes the best alternative.

[9×1=9]

1.Which database language is used for defining schema structures?

a)DML                                                b)DDL

c)DCL                                                d)TCL

 

ans: b)DDL

 

2. Which of the following operations are used to extract data from a
database?

a)SELECT                                         b)DELETE

c)UPDATE                                         d)INSERT

 

ans: a)SELECT

3. Which of the following is NOT a valid PHP data type?

a)String                              b)Float

c)Character                      d)Boolean

 

ans: c)Character

4.Which symbol is used for single-line comments in JavaScript?

a)//                                      b)/* */

c)<!-- -->                            d)**

 

ans a)//

5.What is the default return type of a function in C if no return type is
specified?

a)void                                 b)int

c)char                                 d)float

 

Ans: b)int

6. Which network device is used to connect multiple networks together?

a)Hub                                                b)Switch

c)Router                                            d)Repeater

 

ans: c)Router

7. What is cloud computing?

a)A type of software                                                                                 b)A type of hardware

c)The delivery of computing services over the internet                d)A programming language

 

Ans: c)The delivery of computing services over the internet             

8. Which of the following is NOT a principle of OOP?

a)Encapsulation                            b)Inheritance

c) Compilation                                d)Polymorphism

 

Ans: c) Compilation

9.Which of the following SDLC models is also known as the "linear-
sequential model"?

a)Spiral Model                                b)Waterfall Model

c)Agile Model                                  d)V-Model

 

Ans: b)Waterfall Model

Short Answer Questions: 15×5-25]
GROUP B

10. What is database? Explain any three advantages of DBMS.                                             [2+3=5]

Ans:-

Database:-

It is a collection of interrelated data . These can be stored in the form of tables. A database can be of any size and varying complexity. A database may be generated and manipulated manually or it may be computerized. 

Example: 

Customer database consists the fields as cname, cno, and ccity.



DBMS:

The software tool package that helps gatekeeper and manage data storage, access and maintenances. It can be either in personal usage scope (MS Access, SQLite) or enterprise level scope (Oracle, MySQL, MS SQL, etc). 

DBMS advantages:-

1. Multiple users: 

DBMS allows us to share the data among many users and from different sites. It is done to enter multiple data and for the customers. For a complex database, we assign limited access control for them.

2. Backup: 

Backup means storing the data in different location or machines. It is done by users or the computers themselves to recover the data in the case of failure. Like reserving a ticket online, suppose 100 persons have reserved and the suddenly the system became down, Now what to do in this scenario, we need old data and new data both. Hence the administrator recovers the data from backup.

3.Data security:-

 Obviously, the data for an organization is crucial. What would happen if a hacker or unauthorized person uses it? Our data could be public and  misused by third persons for their own purpose. To avoid  that risk  we assign specific roles to users. We may filter incoming and outgoing data. For this the DBMS is helpful.


OR

Explain second normal form with example.                                                                                  [5]

Ans:-

Second normal form:-

A table is said to be in 2N if it satisfies the following conditions.
1. If it is in 1N.
2.If all non-key attributes are fully functionally dependent on entire primary key, not on only its part.

Example:
Let us consider the following table.

item

colors

price

tax

T-shirt

Red

13

0.45

T-shirt

Blue

13

0.45

polo

red

12

0.4


Here, the table is already in 1N. But it is not in 2N because non-key attributes price and tax depend on item not on colors which is a part of primary key(items, colors). This violates the rule for 2N as it says the non-key attribute is functionally depend on primary key fully, not partially.

To convert this into 2N, we are going to break this into two tables as given here.

items

item

colors

T-shirt

Red

T-shirt

Blue

polo

red


and

Tax

item

price

tax

T-shirt

13

0.45

T-shirt

13

0.45

polo

12

0.4


Now it is in 2NF.

11. Write a javascript function that takes two numbers as arguments and returns their sum.[5]

Ans:

<script>
                var a,b;
                function sum(a,b)
                {
            return a+b;
                }
                a=parseInt(prompt("enter a number for a"));
                b=parseInt(prompt("enter a number foor b"));
                document.write(sum(a,b));
        </script>

OR
Write a PHP script to find the largest of three numbers.

Ans:-

<?php
            $number1 = 10;
            $number2 = 25;
            $number3 = 15;
            if ($number1 >= $number2 && $number1 >= $number3) 
            {
                $greatest = $number1;
            
            elseif ($number2 >= $number1 && $number2 >= $number3)
             {
                $greatest = $number2;
            
            else 
            {
                $greatest = $number3;
                }
        echo "The greatest number is: " . $greatest;
?>


12. Explain the concept of inheritance in OOP. How does inheritance help in code reusability?[2+3]

Ans:-

Inheritance:-

                   It is the fundamental concept in OOP programming paradigm. As the name says, we derive some new classes from existing classes. The class we derive from is called main class or super class where as the derived class is called child class or sub class. This derivation helps us to use the properties and methods of parent class by child class. This feature helps us to use the code of parent class by child class without re-writing the code.

second part:
This feature helps us in code re-usability  in following way.
1.Reusing the code: Since  inheritance allows us to use the property and method of suer class, we do not need to write them again and again. So it saves our time. Example: multiple vehicle types(car and truck) share common property from class vehicle.
2.Extensibility: Subclasses can extend the super class by adding new property and methods. Not only that much,  we can add new classes as per demand without modifying existing ones.
3.Easier maintenance: Changes in the parent classes automatically apply to all child classes, making  update easier and consistent.

13 What is e-learning? Write any three advantages of e-learning.                                        [2+3]

Ans:-

e-learning:-

E-LEARNING is a flexible term used to describe a means of teaching through technology such as a network, browser, CDROM or DVD multimedia platforms. In today's world, mostly, we use internet to learn or teach or share the contents. We do not need to be in a fixed location  to learn. It is just like learn 'wherever you go'

Advantages:

1. Availability of same course to millions. 

2. Boon for Working class. 

3. Apprehensive Employers. 


14. What is the purpose of the requirements gathering phase in the SDLC? Explain. [2+3]

 Ans:-

The primary purpose of requirement gathering in SDLC is to accumulate, analyze and document requirements and assumptions of clients/stakeholders for whom possibly system is being developed. In this phase the development team becomes very clear about what is to be provided from the client side, and at later phase helps in defining requirements adhering to the same.

The main reasons to understand requirement can be:

Clarity and Scope Definition:
It simply defines the project scope, functionalities, constraints, and user expectations clearly, avoiding misunderstandings later in the development process.

Foundation for Design and Development:
The gathered requirements serve as the foundation for the system design, development, and testing phases. Accurate requirements ensure that the system is built as per user needs.

Cost and Time Management:
Well-defined requirements help in estimating project cost, time, and resources effectively, reducing the risk of scope creep, rework, and project failure.

Long Answer Questions: [2x8-16]
GROUP C

15.What is computer network? Explain any three types of network topologies with their advantages.
[2+6]

Ans:-
Computer network:-
A computer network, often simply referred to as a network, is a collection of computers and devices connected by communications channels that facilitates communications among users and allows users to share resources with other users. Networks may be classified according to a wide variety of characteristics.

Purpose of networking:-

  • Networking for communication medium (have communication among people;internal or external)
  • Resource sharing (files, printers, hard drives, cd-rom/)
  • Higher reliability ( to support a computer by another if that computer is down)
  • Higher flexibility( different system can be connected without any problems)
  • Scalable (computers and devices can be added with time without changing original network.

Topology:

When we go for networking, we connect some computers in particular layout or design. This design or pattern of connection is called topology.

There are many types;

Bus topology:

A linear bus topology consists of a main run of cable with a terminator at each end (See fig. 1). All nodes (file server, workstations, and peripherals) are connected to the linear cable.


Fig. 1. Linear Bus topology

Advantages of a Linear Bus Topology

  • Installation is easy and cheap to connect a computer or peripheral to a linear bus.

  • Requires less cable length than a star topology.


Star topology:-

A star topology is designed with each node (file server, workstations, and peripherals) connected directly to a central network hub, switch, or concentrator (See fig. 2).
Data on a star network passes through the hub, switch, or concentrator before continuing to its destination. The hub, switch, or concentrator manages and controls all functions of the network.
It also acts as a repeater for the data flow. This configuration is common with twisted pair cable; however, it can also be used with coaxial cable or fiber optic cable.

                Fig. 2. Star topology

Advantages of a Star Topology

  • Easy to install and wire.

  • No disruptions to the network when connecting or removing devices.

  • Easy to detect faults and to remove parts.

Mesh topology

The mesh topology incorporates a unique network design in which each computer on the network connects to every other, creating a point-to-point connection between every device on the network. The purpose of the mesh design is to provide a high level of redundancy.

It needs/uses n(n-1)/2 channels(paths) and n-1 input/ output ports. If one network cable fails, the data always has an alternative path to get to its destination.


Advantages:
  • Provides redundant paths between devices
  • The network can be expanded without disruption to current users.

16. Write a C program to read and display employee details using a structure. [Define a structure Employee to store employee name (string), ID (integer), and salary (float)]. Write a program to input values for these fields and then display them.

Ans:
#include <stdio.h>
struct Employee 
{
    char name[50];
    int id;
    float salary;
};
int main()
{
    struct Employee emp;
    printf("Enter employee name: ");
    gets(emp.name);
    printf("Enter employee ID: ");
    scanf("%d", &emp.id);
    printf("Enter employee salary: ");
    scanf("%f", &emp.salary);
    printf("\n--- Employee Details are:---\n");
    printf("Name   : %s\n", emp.name);
    printf("ID     : %d\n", emp.id);
    printf("Salary : %.2f\n", emp.salary);
    return 0;
}

OR

What is pointer? Write a C program to add two numbers using call by reference.                          [2+6]

Ans:-

Pointer:-

A pointer is a specific variable that stores the memory address in C of another variable. Rather than keeping a data value directly, a pointer keeps the address where the value is saved in memory. Because they allow us to access and change variables indirectly using their addresses, pointers are powerful.

Syntax:

return type * variable name;

Example:
int *pt;

Second part:-

#include <stdio.h>
void addNumbers(int *, int *) ;
int main() 
{
    int num1, num2;
    printf("Enter first number: ");
    scanf("%d", &num1);
    printf("Enter second number: ");
    scanf("%d", &num2);
    addNumbers(&num1, &num2);
    return 0;
}
void addNumbers(int *a, int *b) 
{
    int sum;
    sum = *a + *b;
  printf("the sum is:%d",sum);
}


THE END