-->

Thursday, May 29, 2025

c program to know a matrix is identity or not | matrix examples in c

Array programs collection C

/* to know a matrix of order n is identity or not

1 0 0
0 1 0
0 0 1
*/
#include<stdio.h>
int main()
{
int n,i,j,is_Identity=0;
printf("enter the size of matrix\n");
scanf("%d",&n);
int matrix[n][n];
printf("enter elements of given matrix\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
scanf("%d",&matrix[i][j]);
}
}
for(i=0;i<=n-1;i++)//loop iteration for row
{
for(j=0;j<=n-1;j++)//loop iteration for column
{
if((i==j && matrix[i][j]!=1)||(i!=j && matrix[i][j]!=0))// checking the condition
// two conditons to bes tested
//Check if the current element is on the diagonal (i == j)
        // In the identity matrix, diagonal elements must be 1
        // Also check if the element is not on the diagonal (i != j)
        // In identity matrix, non-diagonal elements must be 0
is_Identity=1;
break;
}
}
printf("the matrix is:\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
printf("%5d",matrix[i][j]);
}
printf("\n");
}
if(is_Identity==0)
{
printf("The matrix is identity");
}
else
{
printf("the matrix is not identity");
}
return 0;
}

Output:-

c program to know a matrix is identity or not



c program to print sum of two matrices of order mxn | 2D Array-matrix examples

Array programs in C 


/* to find sum of two matrix of order mxn

*/

#include<stdio.h>

int main()

{

int m,n,i,j;

printf("enter m as rows and n as columns\n");

scanf("%d%d",&m,&n);//if m=3 then the loop would run for 0,1,2

int m1[m][n],m2[m][n];

printf("enter elements for first matrix m1\n");

for(i=0;i<=m-1;i++)

{

for(j=0;j<=n-1;j++)

{

printf("enter element for location %d %d\n",i,j);

scanf("%d",&m1[i][j]);

}

}

printf("enter elements for second matrix m2\n");

for(i=0;i<=m-1;i++)

{

for(j=0;j<=n-1;j++)

{

printf("enter element for location %d %d\n",i,j);

scanf("%d",&m2[i][j]);

}

}

printf("the sum of two matrices is:\n");

for(i=0;i<=m-1;i++)

{

for(j=0;j<=n-1;j++)

{

printf("%d",m1[i][j]+m2[i][j]);

}

printf("\n");

}

return 0;

}


Output:-

c program to find sum of two matrices



c program to print transpose of matrix of order 3x2 | 2D Array-matrix examples

 Array programs collections

/* program to find transpose of given matrix of order 3x2

*/

#include<stdio.h>

int main()

{

int matrix[3][2];

int i,j;

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

{

for(j=0;j<=1;j++)

{

printf("data for %d %d location is:",i,j);

scanf("%d",&matrix[i][j]);

}

}

printf("the matrix before transpose is:\n");

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

{

for(j=0;j<=1;j++)

{

printf("%d",matrix[i][j]);

}

printf("\n");

}

printf("the matrix after transpose is:\n");

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

{

for(j=0;j<=2;j++)

{

printf("%d",matrix[j][i]);

}

printf("\n");

}

return 0;

}


Output:

c program to transpose a matrix



Wednesday, May 28, 2025

c program to print diagonal elements | 2D Array-matrix examples

Array program collection in C


/* program to input elements of a 
matrix of order 3x3 and print only main diagonal elements

 1 2 3
 4 5 6
 7 8 9
 the output would be 1
  5
  6
*/
#include<stdio.h>
int main()
{
int a[3][3];//array/matrix declaration of size 3x3
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("enter element for %d %d location",i,j);
scanf("%d",&a[i][j]);//input for matrix
}
}
for(i=0;i<=2;i++)//it is for row
{
for(j=0;j<=2;j++)//it is for column
{
if(i==j) //condition/logic to print the values
printf("%d",a[i][j]);
else
printf(" "); //printing none if the condition is false
}
printf("\n");
}
return 0;
}

Output:-

c program to print diagonal elements



c program to input 2D array element | 2D Array(matrix) examples

 

Matrix program in C[2D examples]




/* 2D array input an output */

#include<stdio.h>
#define row 200
#define column 200
int main()
{
int a[row][column];
int r,c;
int i,j;
printf("enter row and column[0-199] to be used for matrix\n");
scanf("%d%d",&r,&c);//rows and column input
for(i=0;i<=r-1;i++)//for row
{
for(j=0;j<=c-1;j++)//for columns
{
printf("enter element for location %d %d\n",i,j);
scanf("%d",&a[i][j]);
}
}
printf("the matrix is:\n");
for(i=0;i<=r-1;i++)//for row
{
for(j=0;j<=c-1;j++)//for columns
{
printf("%5d",a[i][j]);//printing input with max. width of 5 characters.
}
printf("\n");
}
return 0;
}

Output:-

C program to input elements of mxn matrix



c program to initialize 2D array | 2D Array examples

2D array programs


 /* program to  initialize 2D array*/

#include<stdio.h>
int main()
{
int a[2][2]={{12,13},{14,15}};
int i,j;
for(i=0;i<=1;i++)//for row
{
for(j=0;j<=1;j++)//for columns
{
printf("%3d",a[i][j]);
//%3d means upto 3 trailing spaces
}
printf("\n");
}
return 0;
}

output:-

program to initialize 2D array


Tuesday, May 27, 2025

c program to copy array elements to another | Array examples

Array programs in C


/* program to copy one array elements 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 array elements to another array



c program to sort numbers in ascending order | Array examples

C Array programs

C program to sort the numbers



/*1D array to sort elements
if we have 32,12,43,22,5
after sorting, we have 5,12,22,32,43
*/
#include<stdio.h>
int main()
{
int a[5];
int i,j,temp;
for(i=0;i<=4;i++)
{
printf("enter element for location %d",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<=4;i++)
{
for(j=i+1;j<=4;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<=4;i++)
{
printf("%d\n",a[i]);
}
return 0;
}

Output:

c program to sort the numbers



Tuesday, May 20, 2025

c program to print maximum and minimum value | Array examples

 C array programs

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